JavaScript - What Would This Type Of Script Be Called?
I apologize if I am posting this in the wrong section. I am looking for a code or script for a certain type of game but I can't even figure out what this type of game would be called. The game I am talking about is called "cryptopix" at tanga.com. I would really like to implement something like that on my website that members could create and participate in. If anyone can help point me in the right direction I would be forever grateful. I would assume it's a java script.
Similar TutorialsHi! I'm trying to run this script on Firefox. I'm copying and pasting the whole thing in here just to be safe, but I'm mostly concerned with getting the findLegendary function to call catchPok(). The script executes fine, goes into the battle, but then...does nothing. It runs the catchPok function if I manually click and deselect the "Find Legendary" window option, so alternately, if somebody knows how to make the program automatically click the element at that point to stop repeating the function (maybe?) and it works, I'd be just as happy with that. My best guess is that the autoContinue function might be interfering somehow, since it runs that portion of the code with the manual findLegendary shutoff, but to be honest I'm pretty clueless. What I want it to do is run the catch function through, catch the game pixel, and then go back to repeating. I don't care how this is accomplished as long as it can feasibly loop. The game rules allow botting, so this isn't against any site rules, either. Any and all help/advice is much appreciated! Code: // ==UserScript== // @name Pokemon Vortex Tool // @namespace vortexrising.tk // @include http://*pokemonvortex.org/* // @exclude http://*pokemonvortex.org/adv.php* // ==/UserScript== var legends = [ // Custom // Grass 'Shaymin (Sky)', 'Celebi', 'Latios', 'Latias', 'Rayquaza', 'Shaymin', 'Mew', 'Cresselia', 'Azelf', 'Uxie', 'Mesprit', 'Virizion', 'Genesect', // Grass (water) 'Manaphy', 'Phione', 'Suicune', 'Keldeo', // Ice 'Articuno', 'Suicune', 'Lugia', 'Regice', 'Kyurem', // Cave (land) 'Groudon', 'Arceus', 'Regigigas', 'Palkia', 'Dialga', 'Deoxys', 'Jirachi', 'Registeel', 'Regirock', 'Mewtwo', 'Cobalion', 'Terrakion', 'Virizion', 'Reshiram', 'Zekrom', 'Kyurem', 'Genesect', 'Tornadus', 'Landorus', // Cave (water) 'Kyogre', 'Lugia', 'Keldeo', // Ghost 'Mew', 'Giratina', 'Rotom', 'Mesprit', 'Azelf', 'Uxie', 'Celebi', 'Darkrown', 'Darkrai', // Electric 'Zapdos', 'Raikou', 'Jirachi', 'Darkrai', 'Darkrown', 'Thundurus', 'Zekrom', 'Genesect', // Fire 'Heatran', 'Ho-oh', 'Moltres', 'Entei', 'Reshiram', 'Victini' ]; var settings = { 'keys': ['autoBattle', 'findRare', 'findLegendary','catchPok','findNewpoke'], 'data': {}, 'save': function() { for (var i = 0; i < this.keys.length; i++) { GM_setValue(this.keys[i], this.data[this.keys[i]]); } }, 'load': function() { for (var i = 0; i < this.keys.length; i++) { this.data[this.keys[i]] = GM_getValue(this.keys[i], false); } } }; var movPos = 0; function moveAround() { movPos += 10; if (movPos > 360) { movPos = 0; } var xpos = parseInt(Math.sin(movPos * (Math.PI / 180))*10); var ypos = parseInt(Math.cos(movPos * (Math.PI / 180))*10); unsafeWindow.PlayRequest(xpos + 14, ypos + 14, parseInt(Math.random()*8)+1); /* var btnArrow = unsafeWindow.document.querySelector('#arrows img[onclick]') if (btnArrow) { btnArrow.click(); } else { unsafeWindow.console.info('No buttons?'); }*/ } function catchPok() { try { var btnPo = unsafeWindow.document.querySelector('#battleForm input[type="submit"][value="Continue"]'); if (btnPo) { btnPo.click(); } var radMaster = unsafeWindow.document.querySelector('#itemForm input[type="radio"][value="Master Ball"]'); if (radMaster) { radMaster.click(); } var btnItem = unsafeWindow.document.querySelector('#itemForm input[type="submit"][value="Use Item"]'); if (btnItem) { btnItem.click(); } var btnCont2 = unsafeWindow.document.querySelector('#battleForm input[type="submit"][value="Continue!"]'); if (btnCont2) { btnCont2.click(); } var linkReturnToMap = unsafeWindow.document.querySelector('.optionsList a'); if (linkReturnToMap && linkReturnToMap.textContent.trim() == 'Return to the Map') { settings.data.nextBattle = new Date().getTime() + 10000; unsafeWindow.location.href = linkReturnToMap.href; } }catch (e) { unsafeWindow.console.warn('Exception: ', e); } } function findNewpoke() { var aPoke = unsafeWindow.document.querySelector('#appear p'); var oldPoke = unsafeWindow.document.querySelector('#appear strong'); var searchPoke = unsafeWindow.document.querySelector('#alert p') if (!aPoke) { moveAround(); return; } else if (oldPoke) { moveAround(); return; } else if (searchPoke) { moveAround(); return; } else { var btnDo = unsafeWindow.document.querySelector('input[type="submit"][value="Battle!"]'); if (btnDo) { btnDo.click(); } catchPok(); return; } } function findLegendary() { var wildText = unsafeWindow.document.querySelector('#appear p'); if (!wildText) { moveAround(); return; } wildText = wildText.textContent.trim(); for (var i = 0; i < legends.length; i++) { if (wildText.match(legends[i])) { var btnDo = unsafeWindow.document.querySelector('input[type="submit"][value="Battle!"]'); if (btnDo) { btnDo.click(); } catchPok(); return; } } moveAround(); } function findRare() { var wildText = unsafeWindow.document.querySelector('#appear p'); if (!wildText) { moveAround(); return; } wildText = wildText.textContent.trim(); if (!wildText.match(/Wild (Shiny|Shaymin (Sky)|Celebi|Latios|Latias|Rayquaza|Shaymin|Mew|Cresselia|Azelf|Uxie|Mesprit|Virizion|Genesect|Manaphy|Phione|Suicune|Keldeo|Articuno|Lugia|Regice|Kyurem|Groudon|Arceus|Regigigas|Palkia|Dialga|Deoxys|Jirachi|Registeel|Regirock|Mewtwo|Cobalion|Terrakion|Reshiram|Zekrom|Tornadus|Landorus|Kyogre|Giratina|Rotom|Zapdos|Raikou|Darkrai|Darkrown|Thundurus|Heatran|Ho-oh|Moltres|Entei|Victini)/)) { moveAround(); return; } unsafeWindow.console.info('Rare found ', wildText); } function autoBattle() { try { var btnContinue = unsafeWindow.document.querySelector('#battleForm input[type="submit"][value="Continue"]'); if (btnContinue) { btnContinue.click(); } var btnContinue2 = unsafeWindow.document.querySelector('#battleForm input[type="submit"][value="Continue!"]'); if (btnContinue2) { btnContinue2.click(); } var btnAttack = unsafeWindow.document.querySelector('#battleForm input[type="submit"][value="Attack!"]'); if (btnAttack) { btnAttack.click(); } var linkReturnToMap = unsafeWindow.document.querySelector('.optionsList a'); if (linkReturnToMap && linkReturnToMap.textContent.trim() == 'Return to the Map') { settings.data.nextBattle = new Date().getTime() + 10000; unsafeWindow.location.href = linkReturnToMap.href; } // check for battle button var btnBattle = unsafeWindow.document.querySelector('#appear form input[type="submit"][value="Battle!"]'); var linkRebattle = unsafeWindow.document.querySelector('.optionsList a'); if (btnBattle) { // wait until 10 seconds since last battle //var delay = GM_getValue('lastBattle'); window.setTimeout(function() { btnBattle.click(); }, 10000); } else if (linkRebattle && linkRebattle.textContent.trim() == 'Rebattle Opponent') { window.setTimeout(function() { unsafeWindow.location.href = linkRebattle.href; }, 10000); } else { // if not found, click a direction var btnArrow = unsafeWindow.document.querySelector('#arrows img[onclick]') console.info('arrow', btnArrow); if (btnArrow) { btnArrow.click(); } } } catch (e) { unsafeWindow.console.warn('Exception: ', e); } } function autoContinue() { if (settings.data.findRare) { findRare(); } if (settings.data.autoBattle) { autoBattle(); } if (settings.data.findLegendary) { findLegendary(); } if (settings.data.catchPok) { catchPok(); } if (settings.data.findNewpoke) { findNewpoke(); } } unsafeWindow.AjaxRequest = function () { if (!this.xmlhttp) { try { // Try to create object for Firefox, Safari, IE7, etc. this.xmlhttp = new XMLHttpRequest(); } catch (e) { try { // Try to create object for later versions of IE. this.xmlhttp = new ActiveXObject('MSXML2.XMLHTTP'); } catch (e) { try { // Try to create object for early versions of IE. this.xmlhttp = new ActiveXObject('Microsoft.XMLHTTP'); } catch (e) { // Could not create an XMLHttpRequest object. return false; } } } } this.method = 'post'; this.async = true; this.url; this.query = ''; this.data = ''; this.reponseText; this.reponseXML; this.responseHandler; this.abortHandler; this.showLoading = false; this.send = function () { if (this.method && this.url) { var self = this; this.xmlhttp.onreadystatechange = function () { if (self.xmlhttp.readyState == 4) { if (self.xmlhttp.status && (self.xmlhttp.status == 200 || self.xmlhttp.status == 304)) { //unsafeWindow.console.info('success', self); self.responseText = self.xmlhttp.responseText; if (self.xmlhttp.responseXML) { self.responseXML = self.xmlhttp.responseXML; } else { self.responseXML = null; } if (self.responseHandler) { self.responseHandler(); var evt = document.createEvent('Event'); evt.initEvent('gm:ajaxhook', false, true); document.dispatchEvent(evt); //autoContinue(); } } else { showAlert('<p>An error occured while requesting the data.</p><p>Status Msg: ' + self.xmlhttp.statusText + '</p><p><input type="button" name="ok" value="OK" onclick="removeAlert();" id="alertFocus"></p>'); } if (self.showLoading && self.loading) { self.loading.style.visibility = 'hidden'; } } } if (this.showLoading) { this.displayLoading(); } this.xmlhttp.open(this.method, this.url + '?' + encodeURI(this.query), this.async); if (this.method == 'post') { this.xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); } this.xmlhttp.send(encodeURI(this.data)); } else { showAlert("<p>An error occured while requesting the data.</p><p>No method, URL, and/or query string provided.</p><p><input type=\"button\" name=\"ok\" value=\"OK\" onclick=\"removeAlert();\" id=\"alertFocus\"></p>"); } } this.abort = function () { this.xmlhttp.onreadystatechange = function () {}; this.xmlhttp.abort(); if (this.abortHandler) { this.abortHandler(); } } this.getFormValues = function (form) { for (i = 0; i < form.elements.length; i++) { switch (form.elements[i].type) { case 'text': case 'hidden': case 'password': case 'textarea': this.data += form.elements[i].name + "=" + form.elements[i].value + "&"; break; case 'checkbox': case 'radio': if (form.elements[i].checked) this.data += form.elements[i].name + "=" + form.elements[i].value + "&"; break; case 'select-one': this.data += form.elements[i].name + "=" + form.elements[i].options[form.elements[i].selectedIndex].value + "&"; break; } } this.data = this.data.substr(0, (this.data.length - 1)); } this.appendHTML = function (object, flag) { if (this.xmlhttp.responseText) { if (flag) { object.innerHTML = this.responseText; } else { object.innerHTML += this.responseText; } } else {} } this.displayLoading = function () { if (this.showLoading == 'sidebar') { this.loading = document.getElementById('sidebarLoading'); this.loading.style.height = document.getElementById('sidebar').offsetHeight - 2 + 'px'; this.loading.style.width = document.getElementById('sidebarContent').offsetWidth + 'px'; this.loading.innerHTML = '<p style="text-align: center; margin-top: 150px;"><img src="http://static.pokemonvortex.org/images/loading.gif" width="100" height="100" alt="Loading..." /></p>'; } else if (this.showLoading == 'message') // message { this.loading = document.getElementById('messageContent'); this.loading.style.height = document.getElementById('message').offsetHeight + 'px'; this.loading.style.width = document.getElementById('message').offsetWidth + 'px'; this.loading.innerHTML = '<p style="text-align: center; margin-top: 75px;"><img src="http://static.pokemonvortex.org/images/loading.gif" width="100" height="100" alt="Loading..." /></p>'; } else if (this.showLoading == 'messageList') // message list { this.loading = document.getElementById('messageList'); this.loading.style.height = document.getElementById('messageList').offsetHeight + 'px'; this.loading.style.width = document.getElementById('messageList').offsetWidth + 'px'; this.loading.innerHTML = '<p style="text-align: center; margin-top: 50px;"><img src="http://static.pokemonvortex.org/images/loading.gif" width="100" height="100" alt="Loading..." /></p>'; } else if (this.showLoading == 'map') // map { this.loading = document.getElementById('mapLoading') this.loading.innerHTML = '<p style="text-align: center; margin-top: 150px;"><img src="http://static.pokemonvortex.org/images/loading_white.gif" width="100" height="100" alt="Loading..." /></p>'; } else if (this.showLoading == 'live') { this.loading = document.getElementById('loading'); this.loading.style.height = document.getElementById('scroll').offsetHeight + 'px'; if (document.getElementById('scrollContent')) { this.loading.style.width = document.getElementById('scrollContent').offsetWidth + 'px'; } else { this.loading.style.width = document.getElementById('scroll').offsetWidth + 'px'; } this.loading.innerHTML = '<p class="large" style="margin-top: 75px; text-align: center;"><strong>Waiting for the other user to respond...</strong></p><p style="text-align: center;">You have been waiting <span id="waitTime">0 seconds</span>.</p>'; waitTime(0); } else // main { this.loading = document.getElementById('loading'); this.loading.style.height = document.getElementById('scroll').offsetHeight + 'px'; if (document.getElementById('scrollContent')) { this.loading.style.width = document.getElementById('scrollContent').offsetWidth + 'px'; } else { this.loading.style.width = document.getElementById('scroll').offsetWidth + 'px'; } this.loading.innerHTML = '<p style="text-align: center; margin-top: 150px;"><img src="http://static.pokemonvortex.org/images/loading.gif" width="100" height="100" alt="Loading..." /></p>'; } this.loading.style.visibility = 'visible'; } } function createToggler(container, title, varname) { var toggleEnable = unsafeWindow.document.createElement('p'); container.appendChild(toggleEnable); toggleEnable.innerHTML = title + ' <b>' + (settings.data[varname] ? 'Enabled' : 'Disabled') + '</b>'; toggleEnable.addEventListener('click', function() { settings.data[varname] = !settings.data[varname]; toggleEnable.innerHTML = title + ' <b>' + (settings.data[varname] ? 'Enabled' : 'Disabled') + '</b>'; settings.save(); autoContinue(); }, false); } function init() { var iframes = unsafeWindow.document.getElementsByTagName('iframe'); for (var i = 0; i < iframes.length; i++) { iframes[i].parentNode.removeChild(iframes[i]); } var sty = unsafeWindow.document.createElement('style'); unsafeWindow.document.querySelector('head').appendChild(sty); sty.textContent = '#fscctrl { background: green; border: 1px solid yellow; cursor:pointer; margin: auto; padding: 10px; width: 1010px; } #fscctrl p { margin: 0; } #alert{position:absolute; z-index: 1; background:#ffc; padding: 0 10px; right: 0; width: 100px;} #alert p { margin: 0; } #loading {z-index: 0; top: 0; height: 200px;} #loading p {margin-top:0 !important;} #header{ height: 70px; }'; unsafeWindow.disableSubmitButton = function(form) { for (i = 0; i < form.elements.length; i++) { if (form.elements[i].type == 'submit') { form.elements[i].value = 'Please Wait... or click again - by rockingdo'; } } return true; } settings.load(); document.addEventListener('gm:ajaxhook', function() { autoContinue(); }, false); var container = unsafeWindow.document.createElement('div'); unsafeWindow.document.body.insertBefore(container, unsafeWindow.document.body.firstChild); container.setAttribute('id', 'fscctrl'); createToggler(container, 'Auto-battle', 'autoBattle'); createToggler(container, 'Find Rare', 'findRare'); createToggler(container, 'Find Legendary', 'findLegendary'); createToggler(container, 'Catch Pokemon', 'catchPok'); createToggler(container, 'Find New Pokemon', 'findNewpoke'); autoContinue(); } init(); Hi, I have a form that I am submitting using JQuery, if I copy and paste the form into my main page, everything works fine. If I try to call the form in a separate page to onload none of the buttons work. Is there away around this? Not sure if providing my script helps or not, but just in case here it: Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <title>Messages</title> <head> <link rel="stylesheet" type="text/css" href="style.css" /> <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.3/jquery.min.js"></script> <script type="text/javascript"> $(document).ready(function (){ $('#submitNewSend, #submitNewSend2, #submitNewSave, #submitNewSave2').click(function(){ var btn = $(this).attr('id'); if(btn == 'submitNewSend'){ file = 'insertMessage.php'; Msg = 'Your message has been sent'; } else if(btn == 'submitNewSend2'){ file = 'insertMessage.php'; Msg = 'Your message has been sent'; } else if (btn == 'submitNewSave'){ file = 'insertSaveMessage.php'; Msg = 'Your message has been saved'; } else if (btn == 'submitNewSave2'){ file = 'insertSaveMessage.php'; Msg = 'Your message has been saved'; } var data = $('#MessageNew').serialize(); $.post (file,data, function(){ alert(Msg); $('#MessageNew').each (function(){ this.reset(); }); }); return false; }); }); </script> <script type="text/javascript"> function loadXMLDoc(File,ID){ if (window.XMLHttpRequest) { xmlhttp=new XMLHttpRequest(); } else { xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function(){ if (xmlhttp.readyState==4 && xmlhttp.status==200){ document.getElementById(ID).innerHTML=xmlhttp.responseText; } } xmlhttp.open("POST",File,true); xmlhttp.send(); } </script> <head> <body onload="loadXMLDoc('getloadCompose.php','txtHintCompose')"> <br /> <br /> <div id="txtHintCompose"></div> </form> </body> </html> And the getloadCompose.php is: Code: <form action="" method="post" name="MessageNew" id="MessageNew" autocomplete="OFF"> <table id="new" width="60%"> <tr> <th>Compose Message</th> </tr> <tr> <td class="first"> <input type="button" class="button3" name="submitNewSend2" id="submitNewSend2" value="Send"> <input type="button" class="button3" name="submitNewSave2" id="submitNewSave2" value="Save"> <input type="button" class="button3" name="submitNewCancel" value="Cancel" onclick="loadXMLDocRefresh('getloadInbox.php','txtHintMessage')" /> </td> </tr> <tr> <td> <br /> <label class="two"><b>To:</b></label><input type="text" class="input" name="to" id="to" value=""><input type="text" class="input" name="recipient" id="recipient" value="" onkeyup="showHint(this.value, 'getEmailName.php','txtHintEmailTo')" size="70" /><br /><br /> <div id="txtHintEmailTo"></div> </td> </tr> <tr> <td> <label class="two"><b>Subject:</b></label><input type="text" class="input" name="subject" id="subject" value="enter subject" onclick="this.value='';" onfocus="this.select()" onblur="this.value=!this.value?'enter subject':this.value;" size="70" /><br /><br /> </td> </tr> <tr> <td> <label class="two"><b>Message: </b></label><div class="scroll"><textarea rows="10" cols="75" class="input" name="messsage" id="message">Enter Message</textarea></div><br /><br /><br /> </td> </tr> <tr> <td class="first"> <input type="button" class="button3" name="submitNewSend" id="submitNewSend" value="Send"> <input type="button" class="button3" name="submitNewSave" id="submitNewSave" value="Save"> <input type="button" class="button3" name="submitNewCancel" value="Cancel" onclick="loadXMLDocRefresh('getloadInbox.php','txtHintMessage')" /> </td> </tr> </table> </form> I know I have buttons doing the same function,there is an ease of use reason for it. I can put everything on my main page if necessary, but it wouldn't really be doing exactly what I want it to do. Hi there, I am having a hard time trying to understand this: The script I am using does not work if I write doctype as follows: Code: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> But it does when removing the link: Code: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" > However when I remove the link from the doc type, in IE my selected menu is unaligned; Here is the link. Have you got an idea about why it does not work with the full doc type? Thanks a lot for having a look; Hey everyone I just signed up to this forum. I have been doing a cert IV in Networking IT and part of my course involves javascript. Its all pretty simple, but we dont really have a teacher who I can ask questions. Im have a dead line tonight for a heap of work and I just keep running into so many problems. They are all pretty simple, but I just am at the end of my thread (no pun intended). At the moment Im just working on a box form, and I keep getting object expected errors in relation to my onClick and undefined with my elements. Code: <head> <meta name="author" content= "5h!fTyLiV3z" /> <title>Pay Rate Calculater</title> <SCRIPT LANGUAGE="JavaScript"> function calulatePay() { var elements; var rate = eval(document.payForm.elements[0].value); var hours = eval(document.payForm.elements[1].value); var prod = rate * hours; if (isNaN(element[counter].value) || (element[counter].value == "") ) { if (hours >= 20) { alert("You earned $" + (prod+(hours*2)) + " in " + hours + " hours.") } else { alert("You earned $" + prod + " in " + hours + " hours.") } } else { alert ("Enter numbers please"); } } </SCRIPT> </head> <body> <FORM onSubmit="" NAME="payForm"> <CENTER> <TABLE ALIGN="CENTER" BGCOLOR="#888888" BORDER="3" CELLPADDING="5"> <TR> <TD BGCOLOR="#004080"> <FONT COLOR="#ffffff" FACE="Arial"><B>Calculate My Weekly Pay</B></FONT> </TD> </TR> <TR> <TD> <CENTER> $ <INPUT TYPE="number" NAME="rate" SIZE="11" MAXLENGTH="8" VALUE="Enter pay rate"> : <INPUT TYPE="number" NAME="hours" SIZE="16" MAXLENGTH="8" VALUE="Enter hours worked"> <INPUT TYPE="button" VALUE="Calculate" onClick='calulatePay()'> </CENTER> </TD> </TR> </TABLE> </CENTER> </FORM> </body> I know its all a bit sloppy, but Im just trying to rush though so much work... Any help would be great. If everyone is active tonight I probably will be. Normally I dont have this many problems, but I guess its just exam pressure... Cheers 5hifty I am trying to write a Java Script code, that will calculate hours worked in a day. whenever I try to test the code I get NA in the answer field. Thanks for your help Jason Code: <html> <head> <script type="text/javascript"> function calc(nForm){ var inHour = nForm.inHr; var inMinutes = nForm.inMin; var lunchOutHour = nForm.lunchOutHr; var lunchOutMinutes = nForm.lunchOutMin; var lunchInHour = nForm.lunchInHr; var lunchInMinutes = nForm.lunchInMin; var outHour = nForm.outHr; var outMinutes = nForm.outMin; var linearInTime = 60*(inHour)+(inMinutes); var linearLunchOutTime = 60*(lunchOutHour)+(lunchOutMinutes); var linearLunchInTime = 60*(lunchInHour)+(lunchInMinutes); var linearOutTime = 60*(outHour)+(outMinutes); if (linearLunchOutTime < linearInTime || linearLunchInTime < linearLunchOutTime || linearOutTime < linearLunchInTime){alert('Invalid Information');return false} var workDay = linearOutTime-linearInTime; var lunchPeriod = linearLunchInTime-linearLunchOutTime; var linearMinutesWorked = workDay-lunchPeriod; var hoursWorked = parseInt(linearMinutesWorked/60); var minutesWorked = linearMinutesWorked-(hoursWorked*60) if (hoursWorked < 10){hoursWorked = "0"+hoursWorked} if (minutesWorked < 10){minutesWorked = "0"+minutesWorked} nForm.timeWorked.value = hoursWorked+":"+minutesWorked; } </script> </head> <body> <form name='timeSheet'> Clock In: <label> <input name="inHr" type="text" id="inHr" size="10"> </label>   <label> <input name="inMin" type="text" id="inMin" size="10"> </label> <br> Lunch Out: <label> <input name="lunchOutHr" type="text" id="lunchOutHr" size="10"> </label>   <label></label> <input name="lunchOutMin" type="text" id="lunchOutMin" size="10"> <br> Lunch In: <label> <input name="lunchInHr" type="text" id="lunchInHr" size="10"> </label>   <label> <input name="lunchInMin" type="text" id="lunchInMin" size="10"> </label> <br> Clock Out: <label> <input name="outHr" type="text" id="outHr" size="10"> </label>   <label> <input name="outMin" type="text" id="outMin" size="10"> </label> <br> <br> Time Worked: <input type='text' name='timeWorked' size='5' readonly> <br><br> <input type='button' value="Calculate" onClick="calc(this.form)"> </form> </body> </html> ok i have already found a script to hide a certin file type here it is: Code: x=getAttribute('src')x=x.substring(0, x.indexOf('.jpg')); I don't know javascript so can someone please explain what that does to me and please modify it so it will work with this Code: var displayStyle = (divIndex==selectedIndex || selectedIndex===true)?'inline':'none'; document.getElementById('game_'+divIndex).style.display = displayStyle; basically i want to 1. change the script so it finds .jpg and .JPG 2. use the script in the second script below to basically hide the objects with that extension you can use the second script or make a new one if you want... 3. make it so i can make a link go to javascript:functiontocall() and thats it Thanks in advance and please help it shouldn't take more then a few minutes. suggestions welcome !!
Is there a particular term for writing functions in this manner? I'm interested in doing some reading up on it but don't quite know what to search for. Code: (function(msg){ document.write(msg); })("What's that smell?"); Anyone know of a better CLI base than the one I'm using? It's based off of http://sacrifizezone.blogspot.com/ ------------------------------ So, the way the CLI works is whenever it sees the input which has the matching ID of a DIV, it displays it. Example @ http://ijappy.webs.com/green You can download an early version of the soarce w/ the command "dl src"... It works great, for now, but as I add more & more commands I'm sure the INDEX file will surely begin to... be populated.. So I was wondering if anyone knew a way (using Javascript/Ajax/PHP I really don't care) to "PRINT" a files contents instead of showing a div. So when I typed in 'help' it looked up help.html and printed it's content... Is there such thing? Is this a bad concept? Please, help haha ;D Hi guys, calling a php page through AJAX. and it works Aok. I wanted the ajax backend php file to call a function in the front end page. even a simple alert from the backend php file wont work. Any help is greatly appreciated. My code to call the alert and parent's javascript functions are below. Simple alert Code: echo "<script language='javascript'>alert('Please Help Me');</script>"; Calling Front End Page Function Code: echo "<script language='javascript'>frontend_function();</script>"; Cheers Elabuwa Im looking at how or what this effect is called i am not even sure if it is javascript i assume it is from looking at the code. But i cant seem to convert it to what i want. So if someone could point me to a more simple version of this code or what the technique is called that would be great. Here is the page. http://www.pizzacapers.com.au/the-me...nature-pizzas/ What i am talking about: You click the pizza and it comes up inside of the border picture on the left side of the page. Thanks ok ive searched everywhere online for a webform that is in 2 or more parts... example: (not asking for contact info yet) page 1: name age gender "start request button" (continued application) page 2: email address phone number best time to contact, etc... "submit button" saves info for next page to submit all info from both pages of application to a server etc. I know its possible, i just need to be put on the path... any help is much appreciated! Quote: http://codecanyon.net/item/html-befo...preview/153778 http://codecanyon.net/item/beforeaft...preview/529151 http://www.catchmyfame.com/2009/06/2...eafter-plugin/ I need this effect, I will explain below The first, we have if we slide on the left. when we slide on the right if we slide to END the result will be: OR It's use jquery plugin, I want to find the same things with only javascript, not use jquery. Because, I'm use it on ipod, iphone, android. It's not allow jquery. I'm really need it. please, help me. Thanks for your time Hi I want to build a site that has these two javascript effects. I know HTML, but dont know javscript too well, I know some to be able to change some aspects. I have found some code online that allws me to change the background image with each click of the links. the effect I now want to create is the effect that as you clikc on teh link and the new text appears, the old one drops down andthe new one pops up from the bottom into place. and you have a choice of either a big block ont eh right or a small strip on the bottom depending ont he page. what is this effect called. and does any one know where i might be able to get soem code for it from so i can insert it into my page I hope all this makes sense the site is http://www.peponi-lamu.com many thanks Firebug is giving me no error messages, but alert() message is never triggered. I want the alert() message defined below to alert what the value of the variable result is (e.g. {filter: Germany}). And it doesn't. I think the javascript breaks down right when a new Form instance is instantiated because I tried putting an alert in the Form variable and it was never triggered. Note that everything that pertains to this issue occurs when form.calculation() is called: markup: Code: <fieldset> <select name="filter" alter-data="dropFilter"> <option>Germany</option> <option>Ukraine</option> <option>Estonia</option> </select> <input type="text" alter-data="searchFilter" /> </fieldset> javascript (below the body tag) Code: <script> (function($){ var listview = $('#listview'); var lists = (function(){ var criteria = { dropFilter: { insert: function(value){ if(value) return handleFilter("filter", value); }, msg: "Filtering..." }, searchFilter: { insert: function(value){ if(value) return handleFilter("search", value); }, msg: "Searching..." } } var handleFilter = function(key,value){ return {key: value}; } return { create: function(component){ var component = component.href.substring(component.href.lastIndexOf('#') + 1); return component; }, setDefaults: function(component){ var parameter = {}; switch(component){ case "sites": parameter = { 'order': 'site_num', 'per_page': '20', 'url': 'sites' } } return parameter; }, getCriteria: function(criterion){ return criteria[criterion]; }, addCriteria: function(criterion, method){ criteria[criterion] = method; } } })(); var Form = function(form){ var fields = []; $(form[0].elements).each(function(){ var field = $(this); if(typeof field.attr('alter-data') !== 'undefined') fields.push(new Field(field)); }) } Form.prototype = { initiate: function(){ for(field in this.fields){ this.fields[field].calculate(); } }, isCalculable: function(){ for(field in this.fields){ if(!this.fields[field].alterData){ return false; } } return true; } } var Field = function(field){ this.field = field; this.alterData = false; this.attach("change"); this.attach("keyup"); } Field.prototype = { attach: function(event){ var obj = this; if(event == "change"){ obj.field.bind("change", function(){ return obj.calculate(); }) } if(event == "keyup"){ obj.field.bind("keyup", function(e){ return obj.calculate(); }) } }, calculate: function(){ var obj = this, field = obj.field, msgClass = "msgClass", msgList = $(document.createElement("ul")).addClass("msgClass"), types = field.attr("alter-data").split(" "), container = field.parent(), messages = []; field.next(".msgClass").remove(); for(var type in types){ var criterion = lists.getCriteria(types[type]); if(field.val()){ var result = criterion.insert(field.val()); container.addClass("waitingMsg"); messages.push(criterion.msg); obj.alterData = true; alert(result); initializeTable(result); } else { return false; obj.alterData = false; } } if(messages.length){ for(msg in messages){ msgList.append("<li>" + messages[msg] + "</li"); } } else{ msgList.remove(); } } } $('#dashboard a').click(function(){ var currentComponent = lists.create(this); var custom = lists.setDefaults(currentComponent); initializeTable(custom); }); var initializeTable = function(custom){ var defaults = {}; var custom = custom || {}; var query_string = $.extend(defaults, custom); var params = []; $.each(query_string, function(key,value){ params += key + ': ' + value; }) var url = custom['url']; $.ajax({ type: 'GET', url: '/' + url, data: params, dataType: 'html', error: function(){}, beforeSend: function(){}, complete: function() {}, success: function(response) { listview.html(response); } }) } $.extend($.fn, { calculation: function(){ var formReady = new Form($(this)); if(formReady.isCalculable) { formReady.initiate(); } } }) var form = $('fieldset'); form.calculation(); })(jQuery) Thanks for response. Ok, so basically what I've got is a button which when clicked, "opens" a section of the page. I also need the button to "jump" to this section of the page, because it's below the current content and won't be visible. What I've got so far is ... Javascript <script language="javascript"> function toggle() { var ele = document.getElementById("toggleText"); var text = document.getElementById("displayText"); if(ele.style.display == "block") { ele.style.display = "none"; text.innerHTML = "show"; } else { ele.style.display = "block"; text.innerHTML = "hide"; location="#ordernow" } } function moveWindow(){window.location.hash="ordernow"} </script> HTML ... (The rest of the form is up here) <input name="Button" type="button" class="button" value="Order Now" onclick="toggle();moveWindow()" id="displayText"/> ... (This is the start of the section that becomes visible, along with the anchor point which is highlighted in red.) <div id="toggleText" style="display: none"> <a name="ordernow"></a> <fieldset> <legend>Order Confirmation</legend> <div class="standardinput"> <label>Company:</label> <input name="Company" type="text" class="textinput" id="Company" /> </div> If I put two separate buttons, both functions will work. Basically I need them to be on the same function, not sure how to do that? Thanks so much in advance =) I have something that's called with AJAX when the user enters some text (http://askvoke.com). What I want is to execute some javascript within this "frame". If the frame calls something, with say
Code: <script type=\"text/javascript\"> document.write('h'); </script> in it, then "h" doesn't appear, and neither does anything besides what would normally be shown if I didn't add that. Anyone have a solution? Hi, Sorry very beginner in JS I am using formmail and JS to collect booking info calculates a total and sends to email. Formmail redirects to a thankyou page. Here I can send the total to paypal. I have looked and looked, but cant work out how to pass the total from the booking form to the thankyou page. How can I do this simply. Code not supplied because its nothing wonderous. Thanks Here is the structure I am working with as this html/script was created by the chmProcessor to produce WebHelp files... index.htm contains: Code: <iframe id="mainFrame" name="mainFrame" class="full" src= "frameset.html"> frameset.html contains: Code: <frameset cols="20%,80%"> <frame id="treeFrame" src="tree.html" name="treeFrame" /> <frame id="frameCont" src="2_Welcome.htm" name="Welcome" /> </frameset> tree.html is the navigational panel and contains: Code: <script type="text/javascript" src="tree.js"> </script> I have placed alert() calls in tree.js. When I load index.htm in Chrome, apparently tree.js is not being loaded because I do not see any alert box and the functionality within tree.js does not work. Note: The functionality does work in IE and Firefox If I open tree.html directly in Chrome, the tree.js functionality does get called. I do not know how to solve this problem or why Chrome is not loading the pages and script correctly. Thanks for your help! |