JavaScript - Auto Submit Form Using Ajax Every 5 Minutes Without Reloading Page
he everyone please i want to know how to submit a form using ajax every 5 minutes without reloading page
i have a huge form for exams and i need to submit the form without the need to wait until pressing submit because the user may wait to think about the answer a very long time.. so i want to submit the form and at the same time i cant reload the page as it is in normal submit form.. so how i can submit form in the background without letting the user knows that the form is submitted??? Similar TutorialsI've literally tried everything. Read 26 tutorials, interchanged code, etc. My validation functions all work. My AJAX functions work (tested manually using servlet URL's). The second servlet validates the reCaptcha form that's generated on my webpage. After the form is validated, even if everything's correct, nothing happens upon clicking submit. I even have an alert pop up if with the captcha result, just for middle-layer debugging purposes. I want to do all of my validation clientside; none serverside. However, going to be tough if I can't get my god damn form to submit. I've been puzzled by this for close to 36 hours straight. I can't see, and I'm going to get some rest and hope that there is some useful insight on my problem when I return. html form: Code: <form id="f1" name="form1" onsubmit="validate_form(this); return false;" action="register" method="post"> <table cellspacing="5" style="border: 2px solid black;"> <tr> <td valign="top"> <table cellspacing="5"> <tr> <td>*First name</td> <td align="right"><span id="valid_one"></span></td> <td><input type="text" style="width: 320px;" id="fn" name="fn" onBlur="validate_one();"></td> </tr> <tr> <td align="left">*Last name</td> <td align="right"><span id="valid_two"></span></td> <td><input type="text" style="width: 320px;" id="ln" name="ln" onBlur="validate_two();"></td> </tr> <tr> <td align="left">*Email address</td> <td align="right"><span id="result"></span></td> <td><input type="text" style="width: 320px;" id="mailfield" name="email" onBlur="startRequest();"></td> </tr> <tr> <td align="left">*Phone number</td> <td align="right"><span id="valid_three"></span></td> <td><input type="text" style="width: 320px;" id="pn" name="pn" onBlur="validate_three();"></td> </tr> <tr> <td align="left">*City/Town</td> <td align="right"><span id="valid_four"></span></td> <td><input type="text" style="width: 320px;" id="c" name="c" onBlur="validate_four();"></td> </tr> <tr> <td></td> <td></td> <td> <select name="s"> <option value="AL">Alabama <option value="AK">Alaska <option value="AZ">Arizona <option value="AR">Arkansas <option value="CA">California <option value="CO">Colorado <option value="CT">Connecticut <option value="DE">Delaware <option value="FL">Florida <option value="GA">Georgia <option value="HI">Hawaii <option value="ID">Idaho <option value="IL">Illinois <option value="IN">Indiana <option value="IA">Iowa <option value="KS">Kansas <option value="KY">Kentucky <option value="LA">Louisiana <option value="ME">Maine <option value="MD">Maryland <option value="MA">Massachusetts <option value="MI">Michigan <option value="MN">Minnesota <option value="MS">Mississippi <option value="MO">Missouri <option value="MT">Montana <option value="NE">Nebraska <option value="NV">Nevada <option value="NH">New Hampshire <option value="NJ">New Jersey <option value="NM">New Mexico <option value="NY">New York <option value="MC">North Carolina <option value="ND">North Dakota <option value="OH">Ohio <option value="OK">Oklahoma <option value="OR">Oregon <option value="PA">Pennsylvania <option value="RI">Rhode Island <option value="SC">South Carolina <option value="SD">South Dakota <option value="TN">Tennessee <option value="TX">Texas <option value="UT">Utah <option value="VT">Vermont <option value="VA">Virginia <option value="WA">Washington <option value="WV">West Virginia <option value="WI">Wisconsin <option value="WY">Wyoming </select> </td> </tr> <tr> <td> <br> </td> </tr> <tr> <td></td> <td></td> <td><span id="error"></span></td> </tr> <tr> <td valign="top">*Anti-Spam Verification</td> <td></td> <td id="reCaptcha"></td> </tr> </table> </td> <td valign="top"> <table cellspacing="5"> <tr> <td align="left">*Affiliation</td> <td align="right"><span id="valid_five"></span></td> <td><input type="text" style="width: 320px;" id="affl" name="affl" onBlur="validate_five();"></td> </tr> <tr> <td align="left">*Research Area:</td> <td align="right"><span id="valid_six"></span></td> <td><input type="text" style="width: 320px;" id="ra" name="ra" onBlur="validate_six();"></td> </tr> <tr> <td valign="top" align="left">*Research Overview</td> <td align="right"><span id="valid_seven"></span></td> <td><textarea cols="38" rows="6" id="ro" name="ro" onKeyDown="limitText(this.form.ro,this.form.countdown,500)" onKeyUp="limitText(this.form.ro,this.form.countdown,500)" onBlur="validate_seven();"></textarea></td> </tr> <tr> <td></td> <td></td> <td><font size="1">You have <input readonly type="text" name="countdown" size="1" value="500"> characters remaining.</font></td> </tr> <tr> <td align="left">*Talk Availability</td> <td></td> <td> <input type="radio" name="ta" value="In person">In person <input type="radio" name="ta" value="Online">Online <input type="radio" name="ta" value="Both" checked>Both </td> </tr> <tr> <td align="left" valign="top">Links</td> <td></td> <td> <table id="linkTable" border="0"> <td><input type="text" style="width: 320px;" name="link"></td> <td><div id="result"></div></td> </table> </td> <td align="left" valign="top"><input type="button" value="Add Link" onclick="addLink('linkTable')"></td> </tr> <tr> <td></td> <td><span style="color: red;"></span></td> </tr> </table> </td> </tr> </table> <br /> <input type="submit" id="submit" name="submit" value="Submit Form"> </form> Javascript file: Code: /* * script.js - ajax and table functions */ var xmlHttp; // global instance of XMLHttpRequest var xmlHttp2; // second for captcha functions var validAjax = new Boolean(); var validCaptcha = new Boolean(); var valid_one = new Boolean(); var valid_two = new Boolean(); var valid_three = new Boolean(); var valid_four = new Boolean(); var valid_five = new Boolean(); var valid_six = new Boolean(); var valid_seven = new Boolean(); function init() { showRecaptcha('reCaptcha'); // Separate booleans for AJAX funcs validAjax = false; validCaptcha = false; // Booleanse for fields that don't require servlet validation valid_one = false; valid_two = false; valid_three = false; valid_four = false; valid_five = false; valid_six = false; valid_seven = false; } function showRecaptcha(element) { Recaptcha.create("6Le1a8ESAAAAAGtxX0miZ2bMg0Wymltnth7IG-Mj", element, {theme: "red", callback: Recaptcha.focus_response_field}); } function validate_form() { if (valid_one && valid_two && valid_three && valid_four && validEmail) { startCaptchaRequest(); if (validCaptcha) { return true; } } else { alert("Submission contains errors. Please fill out all required fields before submitting."); return false; } } function validate_one() { if (document.getElementById("fn").value == 0) { valid_one = false; document.getElementById("valid_one").innerHTML = "No"; } else { valid_one = true; document.getElementById("valid_one").innerHTML = ""; } } function validate_two() { if (document.getElementById("ln").value == 0) { valid_two = false; document.getElementById("valid_two").innerHTML = "No"; } else { valid_two = true; document.getElementById("valid_two").innerHTML = ""; } } function validate_three() { if (document.getElementById("pn").value == 0) { valid_three = false; document.getElementById("valid_three").innerHTML = "No"; } else { valid_three = true; document.getElementById("valid_three").innerHTML = ""; } } function validate_four() { if (document.getElementById("c").value == 0) { valid_four = false; document.getElementById("valid_four").innerHTML = "No"; } else { valid_four = true; document.getElementById("valid_four").innerHTML = ""; } } function validate_five() { if (document.getElementById("affl").value == 0) { valid_five = false; document.getElementById("valid_five").innerHTML = "No"; } else { valid_five = true; document.getElementById("valid_five").innerHTML = ""; } } // //function validate_six() { // if (document.getElementById("ra").value == 0) { // valid_six = false; // document.getElementById("valid_six").innerHTML = "No"; // } // else { // valid_six = true; // document.getElementById("valid_six").innerHTML = ""; // } //} // //function validate_seven() { // if (document.getElementById("ro").value == 0) { // valid_seven = false; // document.getElementById("valid_seven").innerHTML = "No"; // } // else { // valid_seven = true; // document.getElementById("valid_seven").innerHTML = ""; // } //} function addLink(tableID) { var table = document.getElementById(tableID); var rowCount = table.rows.length; var row = table.insertRow(rowCount); var cell = row.insertCell(0); var element1 = document.createElement("input"); element1.type = "text"; element1.name = "link" + rowCount; element1.style.width = "320px"; cell.appendChild(element1); } function limitText(limitField, limitCount, limitNum) { if (limitField.value.length > limitNum) { limitField.value = limitField.value.substring(0, limitNum); } else { limitCount.value = limitNum - limitField.value.length; } } function createXmlHttpRequest() { if(window.ActiveXObject) { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } else if(window.XMLHttpRequest) { xmlHttp=new XMLHttpRequest(); } } function startRequest() { createXmlHttpRequest(); var param1 = document.getElementById('mailfield').value; if (param1 == "") { validEmail = false; document.getElementById("result").innerHTML = "Blank"; } else { xmlHttp.open("GET", "http://localhost:1979/PolarSpeakers/servlet/mailCheck.do?e=" + param1, true) xmlHttp.onreadystatechange = handleStateChange; xmlHttp.send(null); } } function handleStateChange() { if(xmlHttp.readyState==4) { if(xmlHttp.status==200) { var message = xmlHttp.responseXML .getElementsByTagName("valid")[0] .childNodes[0].nodeValue; if (message == "Unregistered") { validEmail = true; document.getElementById("result").style.color = "green"; } else { validEmail = false; document.getElementById("result").style.color = "red"; } document.getElementById("result").innerHTML = message; } else { alert("Error checking e-mail address - " + xmlHttp.status + " : " + xmlHttp.statusText); } } } function createCaptchaRequest() { if(window.ActiveXObject) { xmlHttp2=new ActiveXObject("Microsoft.XMLHTTP"); } else if(window.XMLHttpRequest) { xmlHttp2=new XMLHttpRequest(); } } function startCaptchaRequest() { alert('made it to captcha requeswt'); createCaptchaRequest(); var param1 = Recaptcha.get_challenge(); var param2 = Recaptcha.get_response(); xmlHttp2.open("POST", "http://localhost:1979/PolarSpeakers/servlet/captchaCheck.do?c=" + param1 + "&r=" + param2, true) xmlHttp2.onreadystatechange = handleStateChangeCaptcha; xmlHttp2.send(null); } function handleStateChangeCaptcha() { if(xmlHttp2.readyState==4) { if(xmlHttp2.status==200) { var message = xmlHttp2.responseXML .getElementsByTagName("result")[0] .childNodes[0].nodeValue; if (message == "Valid") { alert("captcha valid"); validCaptcha = true; } else { document.getElementById("error").innerHTML = message; validCaptcha = false; } } else { alert("Error checking captcha validity - " + xmlHttp2.status + " : " + xmlHttp2.statusText); } } } Hi, I currently have a form which is submitted using a html submit button. I was wondering what the best way is of using ajax to submit the page without the use of a submit button, and when the page submits, a message is displayed saying thank you for your booking. Thanks. Ok - I'm using an 'off the peg' shopping cart (Mal's e-commerce) that posts items to the cart using a standard form with a submit button. What I want to do is send an item to the cart 'automatically', that is without the user actually filling a form or pressing a 'submit' button. What I send to the cart will be dependant upon the value of a cookie that will have been set at some earlier point in the session. My plan was to use document.write statements to build the 'form' and send it to the shopping cart... Here is the kind of form i will be creating: <form method="post" /> <input type="hidden" name="product" value="XXXXXXXX" /> <input type="hidden" name="price" value="0.00" /> <input type="hidden" name="qty" value="1" /> <input type="submit" value="add to basket" /> </form> 1) 1st problem the product value "XXXXXXXX" actually needs to be 'constructed' out of text plus the value held in the cookie eg... 'here is your COOKIEVALUE product' what i was going to try here was "here is your" + COOKIEVALUE + "product" which doesn't work - but that's what I'm trying to achieve. 2) 2nd problem is the submit 'button' needs to be an automatic 'invisible' action - i don't actually want to give them a button to click i just want to submit it from the coding. Hope that makes some kind of sense! I am trying to write a javascript page where the primary form of user input is an HTML form (shown below) Code: <form id=UI> State: <input type="text" name="state" > Postal abriviation: <input type="text" name="ab"> Capital: <input type="text" name="cap"> <input type="button" name="answer" value="Answer" onClick="check()"> <br> <input type="button" name="show_name" value="Show State" onClick="hint=1;select_state();"> <br> <input type="button" name="show_ab" value="Show Abriviation" onClick="hint=2;select_state();"> <br> <input type="button" name="show_cap" value="Show Capitol" onClick="hint=3;select_state();"> </form> the button named 'answer' does what i want, but when the user pushes enter, if he is in one of the form fields it automatically sends him to the url with all of the form date (www.url.com?state=maryland&ab=md&cap=annapolis) i modified my body tag to run the 'check()' function when enter is pushed, which it does but immideatly sends me to the following url Code: <body onload="first_run()" onkeydown="if (event.keyCode == 13){check()}"> is their any way to disable to the submit built into the form tag either through HTML or javascript? Hi i have a form inside a frame, for example: <html> PHP Code: <body> <div><h1>Header</h1><hr /></div> <iframe height="75%" width="75%" src="iframe.php" frameborder="0"> Iframe should be enabled. </iframe> <div><hr /><h1>Footer</h1></div> </body></html> in iframe.php PHP Code: <form action="http://some-url" id="my_form" name="my_form" method="POST"> <!-- hidden fields goes here ---> <input id="<?php echo $key; ?>" name="<?php echo $key; ?>" value="<?php echo $value; ?>" type="hidden"/> <!-- //hidden fields goes here ---> </form> <script type="text/javascript">document.getElementById("my_form").submit();</script> I would like to know how to submit the iframe.php form so that it goes out of frame. I think we need to tweak this code: PHP Code: <script type="text/javascript">document.getElementById("my_form").submit();</script> Thanks in advance. My html form code is <html> <head> <script type="text/javascript" src="2.js"></script> </head> <body> <h1 id="remain"></h1> <form action="3.php" method="post" id="form1" name="form1"> <input type="text" name="id"> <input type="submit" name="submit" value="submit"> </form> </body> </html> I need to submit the form after coundown.Here is my countdown script file window.onload=counter; function counter() { var seconds = 5; countDown(); function countDown() { document.getElementById("remain").innerHTML=seconds; if(seconds>0) { seconds=seconds - 1; setTimeout(countDown,1000); } if(seconds == 0) { document.form1.submit(); } } } Countdown is working but form does not submit after countdown.Please help me regarding this.Thanks in advance hi, everyone, I'm struggling to figure out how to make my image automatically reload. particularly when the image is randomly selected from a folder. The timing seem to work as the first image disappear after 5 seconds as dictated in the first JavaScript but it simply stays black. Why is the next images not being loaded? http://www.lost-ear-studio.com I'm new with JavaScript big time and tonight is the first time I've really dived into it. Thank you for any advice. 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"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Lost Ear Studio</title><link rel="stylesheet" href="style.css" type="text/css" /> <script type="text/javascript"> window.onload = startInterval; function startInterval() { setInterval("startTime();",5000); } function startTime() { document.getElementById('time').innerHTML = Date(); } </script> <script type="text/javascript"> function resizeToMax(id){ myImage = new Image() var img = document.getElementById(id); myImage.src = img.src; if(myImage.width > myImage.height){ img.style.width = "100%"; } else { img.style.height = "100%"; } } </script> </head> <body> <div id="time"> <script type="text/javascript" language="JavaScript"> NumberOfImagesToRotate = 107; FirstPart = '<img id="bg" src="images/bg/bg_'; LastPart = '.jpg" onload="resizeToMax(this.id)">'; function printImage() { var r = Math.ceil(Math.random() * NumberOfImagesToRotate); document.write(FirstPart + r + LastPart); } </script> <script type="text/javascript" language="JavaScript"> printImage(); </script> </div> Hi, I have a body onload doing multiple things, changing a select option value, changing the form submit action and then auto submitting. Everything works fine until the auto submit part of it. Code: function run() { document.myform.myselect.selectedIndex = 1; document.myform.action = 'page.php?x=1&y=2'; document.myform.submit(); } <body onload="run()"> Thanks for any help with this Hi all, I'm designing something to addon to an existing product. I'm struggling with some javascript problems. I want to submit a hidden field when you click on an image button, rather than it being an actual submit button. It's going to submit the value "1" to a PHP page, but I don't want it to actually have to GO to the PHP page, just submit it within the webpage. Is this possible? Thanks Hello, I don't know if this can be done in Javascript, or requires any other language but i was wondering if this would be possible. I would like to embed this Javascript code in to a PHP file and then for it to run automatically upon the PHP file loading: Code: <td class="smallDesc"> <a name="fb_share" type="button_count" href="http://www.facebook.com/sharer.php">Share</a><script src="http://static.ak.fbcdn.net/connect.php/js/FB.Share" type="text/javascript"></script> </td> The Javascirpt is the Facebook Share button that basically allows users that have Facebook to share the page there currently on in their Facebook status by pressing the button, but if there not logged in it shows the login page, not a problem just continue the script. The current button i which is what i want to load automatically in the PHP file is located here, to test the functionalilty just click "Share" button in blue.. http://watch-movies-online.anyfilman...-Movie-17.html To summarise, i would like the above Javascript code to execute automatically upon pageload of this PHP file.. http://www.watch-movies-online.anyfi...p://google.com. If that could be done, and if this also is possible.. i would like for the "Share" button on the external page that is loaded from the Javascript code above to be clicked automatically so in effect when ever someone visits the PHP page after clicking "Click Here to Watch/Stream 2012 Online For Free" on this page it will automatically load the Facebook Share box, and automatically click the "Share" Button and then close the page if possible, but not required. Please feel free to ask any questions, i'll be happy to answer. Thanks in advance. Best Regards, Jonathan. I have a script (provided by someone else). The problem is the result is not the desired one. Example: I'm getting my hours and minutes in a decimal format. 8:33 is showing as 8.55 I have 3 fields. Field 1 is Time In (2127) Field 2 is Time Out (0600) Field 3 is Total hours worked (8:33) I'm no expert and don't understand JavaScript at all. Here is the script and hope someone can help. Thanks in advance. Cheers, Jim Salo var vTime1 = TextField1.rawValue; var vTime2 = TextField2.rawValue; if (vTime1.length == 4 && vTime2.length == 4) { var vTime1Minutes = parseInt(vTime1.substring(0, 1))*600 + parseInt(vTime1.substring(1, 2))*60 + parseInt(vTime1.substring(2, 4)); var vTime2Minutes = parseInt(vTime2.substring(0, 1))*600 + parseInt(vTime2.substring(1, 2))*60 + parseInt(vTime2.substring(2, 4)); if (vTime1Minutes > vTime2Minutes) this.rawValue = (vTime2Minutes+1440 - vTime1Minutes)/60; else this.rawValue = (vTime2Minutes - vTime1Minutes)/60; } I am running into a problem, that no one else in the world seems to have. When I make a form and submit the page is refreshed, or rather redirected to a state with the values filled after the ? (i.e. http://localhost/comp-267/lab15.html -> http://localhost/comp-267/lab15.html?cardNUm=). I have found solutions that have worked for other people, none of them work for me. I have tested my forms on multiple browsers on multiple systems and the problem persists. Here is one example of my code where this happens. Code: <script type="text/javascript"> function checkCC(myForm) { var ccType; var ccLength; var ccNum = myForm.cardNum.value; if (myForm.cardType.selectedIndex == 0) { ccType = "Visa"; } else if (myForm.cardType.selectedIndex == 1) { ccType = "MasterCard" } else if (myForm.cardType.selectedIndex == 2) { ccType = "AmericanExpress" } switch(ccType) { case "Visa": valid = /^4[0-9]{12}(?:[0-9]{3})?$/; if (valid.test(myForm.cardNum.value)) { alert("This is a Valid Visa Card"); return true; } else { alert("This Card Number is Invalid For Visa"); return false; } break; case "MasterCard": valid = /^5[1-5][0-9]{14}$/; if (valid.test(myForm.cardNum.value)) { alert("This is a Valid MasterCard Card"); } else { alert("This Card Number is Invalid For MasterCard"); } break; case "AmericanExpress": valid = /^3[47][0-9]{13}$/; if (!valid.test(myForm.cardNum.value)) { alert("This is a Valid American Express Card"); return true; } else { alert("This Card Number is Invalid For American Express"); return false; } break; default: valid = /^$/; alert("Card type not found"); return false; } } </script> </head> <body> <h1>Credit Card Validator</h1> <form name="creditCard" onsubmit="return checkCC(this)"> <span class="labels">Card Type:</span> <select name="cardType" size="3"> <option name="visa">Visa</option> <option name="mc">Master Card</option> <option name="amex">American Express</option> </select> <br /> <span class="labels">Card Number:</span> <input name="cardNUm" type="text" size=30 value="" /> <br /> <br /> <input type="submit" value="Death to All" style="background-color:#666666 !important; border:thick groove !important; border-color:#333333 !important" onclick="javascript:return checkCC(this.form)" /> </form> </body> </html> you can find the page he Form Example How do I get this to not happen? I've tried almost every fix I could find that worked for other people none have worked for me. i am new to JS and need help in solving my code that's not reloading the page to download subcat list from db when you select the cat list? Any help is appreciable:
I want to use Javascript to submit a form - without filling the form in physically Is this possible? Let's say a web page has a form that submit First Name and Last Name to the next page Instead of filling in the form and hitting submit, can I submit the data in variables and call the next page somehow using Javascript? Thanks OM hi, I have a google map which shows a car moving along a line that it reads from xml. This is the code that moves the map and the car image: Code: // Returns the bearing in radians between two points. function bearing( from, to ) { // See T. Vincenty, Survey Review, 23, No 176, p 88-93,1975. // Convert to radians. var lat1 = from.latRadians(); var lon1 = from.lngRadians(); var lat2 = to.latRadians(); var lon2 = to.lngRadians(); // Compute the angle. var angle = - Math.atan2( Math.sin( lon1 - lon2 ) * Math.cos( lat2 ), Math.cos( lat1 ) * Math.sin( lat2 ) - Math.sin( lat1 ) * Math.cos( lat2 ) * Math.cos( lon1 - lon2 ) ); if ( angle < 0.0 ) angle += Math.PI * 2.0; if (angle == 0) {crash;} return angle; } function plotcar() { var cosa = Math.cos(angle); var sina = Math.sin(angle); canvas.clearRect(0,0,32,32); canvas.save(); canvas.rotate(angle); canvas.translate(16*sina+16*cosa,16*cosa-16*sina); canvas.drawImage(img,-16,-16); canvas.restore(); } //=============== animation functions ====================== function animate(d) { if (d>eol) { return; } var p = poly.GetPointAtDistance(d); if (k++>=180/step) { map.panTo(p); k=0; } map.panTo(p); marker.setPoint(p); if (supportsCanvas) { if (poly.GetIndexAtDistance(d)>lastVertex) { lastVertex = poly.GetIndexAtDistance(d); if (lastVertex == poly.getVertexCount()) { lastVertex -= 1; } while (poly.getVertex(lastVertex-2).equals(poly.getVertex(lastVertex-1))) { lastVertex-=1; } angle = bearing(poly.getVertex(lastVertex-2),poly.getVertex(lastVertex-1) ); plotcar(); } } setTimeout("animate("+(d+step)+")", tick); } function startAnimation() { eol=poly.Distance(); map.setCenter(poly.getVertex(0),16); map.addOverlay(new GMarker(poly.getVertex(0),G_START_ICON)); map.addOverlay(new GMarker(poly.getVertex(poly.getVertexCount()-1),G_END_ICON)); if (supportsCanvas) { marker = new ELabel(poly.getVertex(0), '<canvas id="carcanvas" width="32" height="32"><\/canvas>',null,new GSize(-16,16)); map.addOverlay(marker); canvas = document.getElementById("carcanvas").getContext('2d'); var p0 = poly.getVertex(0); var p1 = poly.getVertex(1); angle = bearing(p1,p0); plotcar(); } else { marker = new GMarker(poly.getVertex(0),{icon:car}); map.addOverlay(marker); } poly2 = new GPolyline([poly.getVertex(0), poly.getVertex(1), poly.getVertex(2)], 0,0); // map.addOverlay(poly2); setTimeout("animate(0)",2000); // Allow time for the initial map display } It works fine as you can see here but the problem is that if the user clicks the button again without reloading the page, the map moves but the car remains at its last point. From what I can figure out, this means that the startAnimation() function has restarted but the animate(d) function has not restarted. but trying to call the animate(d) function from the button, where the startAnimation() gets called, he Code: <input type="button" onclick="startAnimation();return false;" value="show bus route 1"> results in an error that d is not defined. is there some way of resetting the animate(d) function when the startAnimation() function gets called, so everything goes back to the start? Or is there some other way of "refreshing" everything without reloading the page? thanks in advance. I have a set of tabs that are set with an href that adds a query string to the url such as "?t=1", meaning the first tab is selected. Technically it works just fine but every time I click a tab it reloads the page and I'm not entirely sure how to stop this. I'm using a jquery plugin to handle the query strings. Here's the plugin. Here's the piece of the code that matters: Code: var url = location.search; var tab = $.query.get('t'); init(tab); function init(tab){ $("div.tab").hide(); //hides all the content boxes related to the tabs $("div#tab"+tab).fadeIn("fast"); //Shows the selected tab's content box setInactive(); //Styles unselected tabs setActive(tab); //Styles selected tab } Any help would be greatly appreciated. I'm using meta refresh to refresh my web page. I have a small compose email window that appears via ajax when the user clicks on a name. Is there a way I can disable the screen refresh in my ajax code while they are composing their message? Hey all, I'm trying to make it so that when a user clicks on a radio button, the image that is related to the radio button is displayed next to it (without reloading the page). At the moment all it shows is the image related to the currently saved option, which I'd like to keep on page load. Is this possible? If so, I'd appriciate any help. Here is my code for the radio buttons. Thanks. Code: <tr valign="top"> <td id="community-legal-services-logo-selection"> <p><label><?php _e('<strong class="table_tags">Display the following Community Legal Services logo:</strong>'); ?></p> <p><label for="cls-mono"> <input class="" id="cls-mono" name="cls_logo" type="radio" value="cls_mono" <?php if($general_options['cls_logo'] === 'cls_mono'){ echo 'checked="checked"'; } ?> /> <?php _e('Mono'); ?></label> </p> <p><label for="cls-color"> <input class="" id="cls-color" name="cls_logo" type="radio" value="cls_color" <?php if($general_options['cls_logo'] === 'cls_color'){ echo 'checked="checked"'; } ?> /> <?php _e('Colour'); ?></label> </p> <p><label for="cls-none"> <input class="" id="cls-none" name="cls_logo" type="radio" value="cls_none" <?php if($general_options['cls_logo'] === 'cls_none'){ echo 'checked="checked"'; } ?> /> <?php _e('None'); ?></label> </p> <p> <label><?php _e('<span class="table_tags">Link to the Community Legal Services website<span>'); ?></label> </p> <p> <input class="large_input_box" id="cls-link" name="cls_link" type="text" value="<?php echo $general_options['cls_link']; ?>" /></label> </p> </td> <?php if($general_options['cls_logo'] && $general_options['cls_logo'] !== 'cls_none'){ ?> <td> <img id="community-legal-services-logo-preview" class="image-preview" src="<?php echo $general_options['cls_logo_path']?>" /> </td> <?php } ?> </tr> Hi; I am implementing a Ajax auto suggestion search from database. I find an example from http://www.roscripts.com/Ajax_autosu...abase-154.html . I have not problem with the php part about search from database, but i got a problem from the search from, i added a listerner to input tag, but it still not auto suggest anyword when i type any of word, Could any one help me, Thanks. PHP Code: <html> <head> <title>roScripts - Ajax auto-suggest</title> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <script src="lib/prototype.js" type="text/javascript"></script> <script src="src/scriptaculous.js" type="text/javascript"></script> <script src="src/unittest.js" type="text/javascript"></script> <script src="lib/builder.js" type="text/javascript"></script> <script src="src/controls.js" type="text/javascript"></script> <script src="src/effects.js" type="text/javascript"></script> <link rel="stylesheet" href="css/style.css" type="text/css" /> </head> <body> <div id="container"> <form method="post" action="response.php"> <label for="testinput">Search</label><br /> <input type="text" id="search" name="search" autocomplete="off" class="input" value="" onkeyup="autoSuggest();" /><br /> <div id="update" style="display:none;position:relative;"></div> <input type="image" name="register" class="submit-btn" src="http://www.roscripts.com/images/btn.gif" alt="submit" title="submit" /> </form> <script type="text/javascript" language="javascript" charset="utf-8"> function autoSuggest(){ new Ajax.Autocompleter('search','update','response.php', { tokens: ','} ); Autocompleter.show(); } </script> </div> </body> </html> |