JavaScript - Submit Button Don't Work
Whenever I click the Submit button, which should create a new window showing all the details entered in the form, it doesn't work ideas?
javascript.html Code: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <title>JavaScript</title> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-15"> <!-- The external style sheets --> <link rel="stylesheet" type="text/css" href="mystyle.css"> <script type="text/javascript" src="myjavascript.js"></script> <meta name="keywords" content="CO332"> <meta name="description" content="CO332 Exercise Website"> <meta name="author" content="Bradley Berwick"> </head> <body> <div id="container"> <div id="maincontent"> <div id="header"> <h1> Exercise Website </h1> </div> <div id="leftnav"> <ul> <li><a href="index.html" >Home</a> <li><a href="myjavascript.html" ><span class="currentpage">Services</span></a> <li><a href="#" >TBA</a> <li><a href="#" >TBA</a> </ul> </div> <div id="content"> <h2>About Yourself</h2> <form name="exampleform"> <h3>Name: <input name="yourname" type="text"></h3> <h3>Age: <input name="age" type="text" size="3" Onchange = ' if ( !( this.value > 0 && this.value < 150 ) ) { alert( this.value + " is not a valid age."); this.value=""; // clear age text box }' > </h3> <h3>Gender: <input name="gender" type="radio" value="male"> Male <input name="gender" type="radio" value="female"> Female </h3> <h3>Your favourite colour: <select name="colours"> <option value="None"> <option value="red">Red <option value="green">Green <option value="blue">Blue <option value="pink">Pink <option value="orange">Orange <option value="purple">Purple </select> </h3> <h3>Your hobbies a <br> <input name="running" type="checkbox"> Running <br> <input name="football" type="checkbox"> Football <br> <input name="golf" type="checkbox"> Golf <br> <input name="cycling" type="checkbox"> Cycling </h3> <textarea rows="10" cols="30"> Add comments. </textarea> <p> <input type="reset" value="Clear"> <input name="submit" type="button" value="Submit" onclick='submitForm()';> </p> </form> </div> </div> <div id="footer"> <div id="mailto"> Last updated on 28th Oct 2011<br> Maintained by Bradley Berwick </div> </div> </div> </body> </html> myjavascript.js Code: function displayMessage(msg) { // Open a new window var msgWindow = window.open('', 'Message'); // Write message in the new Window msgWindow.document.write(msg); msgWindow.document.close(); // Raise this window, in case it's not visible msgWindow.focus(); } var hobstring=""; function submitForm() { var nam=document.exampleform.elements["yourname"].value; var age=document.exampleform.elements["age"].value; var gend = document.getElementsByName('gender'); for (var i = 0; i < gend.length; i++) { if (gend[i].checked==true) { var sex=gend[i].value; } } var sel=document.getElementById('color'); var color=sel.options[sel.selectedIndex].value; var hobbs = document.getElementsByName('hobby'); for (var a = 0; a < hobbs.length; a++) { if (hobbs[a].checked==true) { hobstring+=hobbs[a].id+", "; } } var msg="Name: "+nam+"<br>Age: "+age+"<br>Gender: "+sex+"<br>Favorite color: "+color+"<br>Hobbies: "+hobstring; displayMessage(msg); } Similar Tutorialsthis is my code ______________________________________________________________ <pega:when test="$mode-input"> <script language="JavaScript"> function showNextButton() { handleClientEvent('SERVER','MakeScoreOrder','','-1'); /* fetches the data */ var submitClicked = "<p:r n='pyWorkPage.PFRSData.SubmitClicked' />"; var submitClicked = submitClicked.replace(/^\s\s*/, '').replace(/\s\s*$/, ''); var msg = "<p:r n='pyWorkPage.PFRSData.HasMessages' />"; var msg = msg.replace(/^\s\s*/, '').replace(/\s\s*$/, ''); if (submitClicked == "" || msg =="true") { toggleSubmitBtn(0); } else if (submitClicked == "true" || msg =="false") { toggleSubmitBtn(1); } } function toggleSubmitBtn(status) { var submitButton=document.actionForm.submitButton; if(submitButton) { var parentTable=pega.u.d.findParentTable(submitButton); if(parentTable) if(status) { if(parentTable.style.display=='none' || parentTable.style.display=='') { parentTable.style.display='inline'; document.actionForm.submitButton.disabled=false; } } else { parentTable.style.display='none'; document.actionForm.submitButton.disabled=true; } } } </script> <button onClick="showNextButton();" id="PISSubmit" style="vertical-align:middle;"> <span class='buttonLeft'></span> <span class='buttonMiddle'> <span class='buttonText' onmouseover="this.className='buttonTextHover'" onmouseout="this.className='buttonText'">Submit</span> </span> <span class='buttonRight'></span> </button> </pega:when> ___________________________________________________________ On clicking PISsubmit button it should fetch data and display the next button(submitButton).. but on first click nothing happens on second click it fetches the data and third click it displays Next(submitButton)button. Kindly help !! Note: its in pega application. I have created some online software which uses form data to submit to another page. The problem is that I have other submit buttons in the same form which submit to different pages (depending on which button is pressed). The first submit button works fine but all the others only work once. Code: <input class="cssbutton" type='submit' value='Button1' onclick="wbform.action='page1.php'; target='mainFrame'; return true;"> <input class="cssbutton" type='submit' value='Button2' onclick="wbform.action='page2.php'; target='_blank'; return true;"> <input class="cssbutton" type='submit' value='Button3' onclick="wbform.action='page3.php'; target='topFrame'; return true;"> <input class="cssbutton" type='submit' value='Button4' onclick="wbform.action='page4.php'; target='topFrame'; return true;"> <input class="cssbutton" type='submit' value='Button5' onclick="wbform.action='page5.php'; target='_blank'; return true;"> <input class="cssbutton" type='submit' value='Button6' onclick="wbform.action='page6.php'; target='_blank'; return true;"> Any ideas my friends? I am trying to auto submit a login form remotely using .submit() . It's submitting, but for some reason if I use submit() the login isn't processing. However, if I turn off the auto submit and use an actual submit button it logs in just fine. Now, in the form tag there is a call onsubmit for some validation, does .submit() trigger that form onsubmit="" function? Is there something that happens differently when a user clicks a button verses the .submit(). Thanks! Paul OK! I re adjusted some things after some research. Still a bit confused: 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>login</title> <script type="text/javascript"> function encode64(form) { var username=un; var password=pass; var ip=ip; var enKey= 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; var deKey = new Array( -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -1, -1, -1, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1, -1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1 ); var str=new Array(); var ch1, ch2, ch3; var pos=0; while(pos+3<=src.length){ ch1=src.charCodeAt(pos++); ch2=src.charCodeAt(pos++); ch3=src.charCodeAt(pos++); str.push(this.enKey.charAt(ch1>>2), this.enKey.charAt(((ch1<<4)+(ch2>>4))&0x3f)); str.push(this.enKey.charAt(((ch2<<2)+(ch3>>6))&0x3f), this.enKey.charAt(ch3&0x3f)); } if(pos<src.length){ ch1=src.charCodeAt(pos++); str.push(this.enKey.charAt(ch1>>2)); if(pos<src.length){ ch2=src.charCodeAt(pos); str.push(this.enKey.charAt(((ch1<<4)+(ch2>>4))&0x3f)); str.push(this.enKey.charAt(ch2<<2&0x3f), '='); }else{ str.push(this.enKey.charAt(ch1<<4&0x3f), '=='); } } return str.join(''); } var encusername = encode64 (un); var encpass = encode64 (pass); //script andy gave me function checkUrlRandom(url){ var mathRnd = Math.round(Math.random()*10000); if(url.indexOf("?") > 0 ){ url = url + "&rnd=" + mathRnd; }else{ url = url + "?rnd=" + mathRnd; } return url; } //HOW DO I GET THE ENCODED USERNAME AND PASSWORD AND NON ENCODED IP ADDRESS TO POST INTO THE URL UNDENEATH THIS AND THEN GO TO THAT URL? xhr = new XMLHttpRequest(); xhr.open("GET",checkUrlRandom("http://"+ip+"/User.cgi?cmd=get_login&username="+encuseranme+"&password="+encpass+"")); </script> </head> <body> <form name="form" method="get" onclick="encode64(this.form)"> <p> <label for="ip">ip</label> <input type="text" name="ip" id="ip" /> </p> <p> <label for="username">username</label> <input type="text" name="username" id="username" /> </p> <p> <label for="password">password</label> <input type="text" name="password" id="password" /> </p> <p> <input type="submit" name="submit" id="submit" value="click" /> </p> </form> </body> </html> HOW DO I GET THE ENCODED USERNAME AND PASSWORD AND NON ENCODED IP ADDRESS TO POST INTO THE URL AND THEN GO TO THAT URL? thanks -Mike the showUser function has ajax in it that calls a php file that accesses a db to perform some calculations. I wanted to use the clicked function to force required dropdowns to be selected but I cannot seem to get the submit button to do anything. It does nothing when you click it. Not sure how to proceed, have looked everywhere. If anyone has any advice I would really appreciate it. Code: <form id="forecastfilter" action="indexo_beats.php" method="get" onsubmit="clicked(this.value='yes')"> <div class="fc">Date:</div> <select name="date" onchange="showUser(this.value)"> <option value="">-- </option> <option value="Date: Past Hour">Past hour</option> <option value="Date: Past week">Past week</option> <option value="Date: Past month">Past month</option> <option value="Date: Past year">Past year</option> </select> <br /> <div class="fc">Wideouts:</div> <select name="wideouts" onchange="showUser(this.value)"> <option value="">-- </option> <option value="Wideouts: Higher">Revised Higher</option> <option value="Wideouts: Unchanged">Remains Unchanged</option> <option value="Wideouts: Lower">Revised Lower</option> </select> <br /> <div class="fc">QBs:</div> <select name="qbs" onchange="showUser(this.value)"> <option value="">-- </option> <option value="QBs: beat">Above Analyst Estimates</option> <option value="QBs: inline">Inline with Analyst Estimates</option> <option value="QBs: miss">Below Analyst Estimates</option> </select> <br /> <div class="fc">Football:</div> <select name="football" onchange="showUser(this.value)"> <option value="">-- </option> <option value="Football: beat">Above Analyst Estimates</option> <option value="Football: inline">Inline with Analyst Estimates</option> <option value="Football: miss">Below Analyst Estimates</option> </select> <br /> <div class="fc">Sentiment:</div> <select name="sentiment" onchange="showUser(this.value)"> <option value="">-- </option> <option value="Sentiment: good">Good</option> <option value="Sentiment: neutral">Neutral</option> <option value="Sentiment: bad">Bad</option> </select> <div class="searchbutton"> <input type="button" value="Search Draft" /> </div> </form> Hello There, I have form which submitted data by checkbox checked, the checkbox as looks: PHP Code: <input type="checkbox" name="agree" value="1" checked="checked" onclick="document.getElementById('parentTable').className,processForm() = this.checked ? 'vehicleOn' : 'vehicleOff'" /><label for="agree">Agree</label> and the Ajax as following Code: function processForm() { $.ajax({ type: 'POST', url: '<?php echo $send; ?>', data: 'opt1=' + encodeURIComponent($('input[name=\'opt1\']:checked').val() ? $('input[name=\'opt1\']:checked').val() : '') + '&opt2=' + encodeURIComponent($('input[name=\'opt2\']:checked').val() ? $('input[name=\'opt2\']:checked').val() : '') + '&comment=' + encodeURIComponent($('textarea=[name=\'comment\']').val()) + '&agree=' + encodeURIComponent($('input[name=\'agree\']:checked').val() ? $('input[name=\'agree\']:checked').val() : ''), beforeSend: function() { $('.success, .warning').remove(); $('#confirm_button').attr('disabled', 'disabled'); $('#confirm_title').after('<div class="wait"><img src="mage/loading_1.gif" alt="" /> <?php echo $text_wait; ?></div>'); }, complete: function() { $('#confirm_button').attr('disabled', ''); $('.wait').remove(); }, success: function(data) { if (data.error) { $('#confirm_title').after('<div class="warning">' + data.error + '</div>'); } if (data.success) { $('#confirm_title').after('<div class="success">' + data.success + '</div>'); $('input[name=\'opt1\']:checked').attr('checked', ''); $('input[name=\'opt2\']:checked').attr('checked', ''); $('input[name=\'agree\']:checked').attr('checked', ''); } } }); } The Problem is won't work with IE only, I tested it with IE 6, Anyone could suggest me what I could do? any pointers, samples or links I would be appreciate and Thanks a lot. I'm trying to get a submit button to open a thank you page I created (i.e. thankyou.html) only after the user has filled out a series of questions for a form. If they don't fill out the required information, a pop up box informs them to fill out the section (this I have accomplished). I cannot get the submit button to not work if the fields are left un-answered. Can you guys help? Thanks for you help. -------------------------------------------------------------------------- This is what I have so far: <title>Customer Demographic Data Form</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" ></meta> <style type="text/css"> body { font-family: Times New Roman; color: navy; background-color: #CCC } h1, h2, h5 { font-family: Times New Roman; color: black } body,td,th { color: #000; font-family: Times New Roman, Times, serif; } h1 { color: #000; } h2 { color: #000; } h5 { color: #000; } a { font-family: Times New Roman, Times, serif; } h1,h2,h3,h4,h5,h6 { font-family: Times New Roman, Times, serif; } </style> <script type="text/javascript"> function checkForNumber(fieldValue) { var numberCheck = isNaN(fieldValue); if (numberCheck == true) { window.alert("Please enter a numeric value!"); return false; } } function confirmSubmit() { var email = document.forms[0].email.value; if (document.forms[0].fname.value == "" || document.forms[0].lname.value == "") { window.alert("Please enter your first and last name."); document.forms[0].lname.focus(); return false; } else if (document.forms[0].address1.value == "" && document.forms[0].email.value == "") { window.alert("Please enter your Mailing Address or Email Address!"); document.forms[0].address1.focus(); return false; } else if (email.indexOf("@") == -1 && document.forms[0].email.value != "") { window.alert("Please enter a valid e-mail address."); document.forms[0].email.focus(); return false; } else if (email.indexOf(".") == -1 && document.forms[0].email.value != "") { window.alert("Please enter a valid e-mail address."); document.forms[0].email.focus(); return false; } else if(document.forms[0].city.value == '') { window.alert("Please enter your City"); document.forms[0].city.focus(); return false; } else if(document.forms[0].state.value == '') { window.alert("Please enter your State"); document.forms[0].state.focus(); return false; } else if(document.forms[0].zip.value == '') { window.alert("Please enter your Zip Code"); document.forms[0].zip.focus(); return false; } checkCookie() } function checkCookie() { var formInfo = decodeURI(document.cookie); var userInfo = formInfo.split("; "); var lname = userInfo[0].split("="); var fname = userInfo[1].split("="); if (lname[1] == document.forms[0].lname.value && fname[1] == document.forms[0].fname.value) { this.close(true); window.open("FormDenied.html"); return false; } else { setCookie(); return true; } } function setCookie() { var expiresDate = new Date(); expiresDate.setFullYear(expiresDate.getFullYear() + 1); document.cookie = encodeURI("lname=" + document.forms[0].lname.value) + "; expires=" + expiresDate.toUTCString(); document.cookie = encodeURI("fname=" + document.forms[0].fname.value) + "; expires=" + expiresDate.toUTCString(); window.alert("Your information has been saved."); } </script> </head> <body> <p> </p> <h1 align="left" style="text-align: left">Kudler Fine Foods contact form</h1> <form action="" method="get" enctype="application/x-www-form-urlencoded" onsubmit="return confirmSubmit();" onreset="return confirmReset();" > <blockquote> <h2><u>Name</u></h2> <p> <input type="text" name="fname" id="fname" size="25" /> <label for="fname"><strong>First Name</strong><br> <br> </label> <input type="text" name="lname" id="lname" size="15" /> <strong>Last Name</strong></p> <h2>---------------------------------------<br> <u>Address</u> </h2> <p> <input type="text" name="address1" id="address1" size="30" /> <label for="address1"><strong>Address Line 1</strong></label> </p> <p> <input type="text" name="address2" id="address2" size="20" /> <strong>Address Line 2<br> <br> </strong> <input type="text" name="city" id="city" size="20" /> <strong>City</strong> </p> <p> <input type="text" name="state" id="state" size="2" /> <label for="state2"><strong>State</strong></label> </p> <p> <input type="text" name="zip" id="zip" size="10" maxlength="10" onChange="return checkForNumber(this.value);" /> <label for="zip2"><strong>Zip Code</strong></label> </p> <h2>--------------------------------------- </h2> <h2> <u>Other Information</u></h2> <table> <tr> <td width=300><strong>Telephone</strong></td> <td width=300><p><strong>Email address:</strong></p></td> </tr> <tr> <td> <input type="text" name="area" id="area" size="3" maxlength="3" onChange="return checkForNumber(this.value);" /> <input type="text" name="exchange" id="exchange" size="3" maxlength="3" onChange="return checkForNumber(this.value);" /> <input type="text" name="phone" id="phone" size="4" maxlength="4" onChange="return checkForNumber(this.value);" /></td> <td> <input type="text" name="email" id="email" size="30" /></td> </tr> </table> </blockquote> <h5> </h5> <blockquote><blockquote> <h3 align="center"> <input name="Submit" type="button" </h3> </blockquote> </blockquote> </form> </body> </html> I need help making this timed quiz so when you hit submit it goes into a mysql database. right now it just tells you if you answered correctly or not Here is the code: what color is the grass? <input type = "text" id = "answer"> <input type = "button" id = "time" onclick="answer()"> <script type = "text/javascript"> var n = 60; // modify this for number of seconds to answer document.getElementById( 'time').value = "Answer in " + n + " seconds"; var i = setInterval('count()' , 1000); var tooLate; function count() { tooLate = 0; n--; if(n >=0) { document.getElementById( 'time').value = "Answer in " + n + " seconds"; } else { clearInterval(i); alert("Too late!"); document.getElementById('answer').value = ""; tooLate = 1; } } function answer() { var correct = "green"; // This is the correct answer if (tooLate == 0) { if(document.getElementById( 'answer').value == correct) { clearInterval(i); alert("Right Answer with " + n + " seconds remaining"); } else{ clearInterval(i); alert("Incorrect! The answer was " + correct); } } } </script> Hi everyone, I have a problem with something I am trying to do. I have a submit button and once I press it I want it to add a post value to my website. For example my website is www.something.net/test.php and once I press it I want it to refresh the site and becomes something like www.something.net/test.php&ca=test In other words I want it to use POST and then using GET I can get the value of the POST. I have posted this under javascript because I believe I have a problem with the javascript I use. Here is the javascript and the button I use Javascript Code: function reload(val) { //var val=form.accept.id; self.location='test.php?ca=' + val ; } Button Code: <form name='form1' method='post' action='' STYLE='margin: 0px; padding: 0px;'> <input type='submit' name='accept' id='trial' value='Approve' onclick=\"reload(test)\" /> </form></div></td>"; Can you please help me with that? Hi all, i have seen that there is an input type 'reset' which i presum clears all fields in a form? But anyway i did not know this existed and my implementation requires a bit more sophistication so i had already written code to do a custom reset of the boxes whilst keeping and updating certain key values. This works fine. My question is, for the actual 'submit' of the data in a form do i have to use a button of type 'submit'? It is actually better for me in this instance that i do not as the special message windows i am using will close - and in the case of errors in the user input this is not desirable - so i have written the error handling etc with window staying open in mind, so that user can correct their errors and resubmit. To accomplish this i changed my input into type 'button' and it works fine When i click 'the submit button' it checks fields for valid data first - can i use its return value to somehow activate or not the actual form data sending? Like i have Code: <input type = "button" style = "font-size:18;" value= " Submit "onclick = "CheckValid()"/> I could be calling 'SendForm()' or something here instead and have check valid called from within SendForm() i norder to determin it's return type, how can i use this to decide if the form data is valid to send or not? and how could i use the return value in the html like this? should i A: think it is possible to send all the data from within the onclick function so i use that to decide if it gets sent from internal calls there and display thank you message if so, if not display error message. should i B: Disable the sending button until the fields contain valid data? Or use a second button to confirm data then allow a submit button to be pressed? <input type="image" src="uploads/button_in_cart.gif" border="0" alt="Add to Cart" title=" Add to Cart " onclick="addtocart(1);"> in addtocart function I do some checking how can i change that if after some checking my variable valid=0 that it does not allow the user to submit the form? I am looking for some help similar to this old post: http://www.codingforums.com/showthread.php?t=19588 I want my radio buttons to become submit buttons as well. So when a user clicks on a radio button it submits the action and refreshes the page accordingly. As of now using only using onclick="this.form.submit()" the page only refreshes with no change. Here is a copy of the entire form. It is a custom shipping options form (I did not create it). Any help would be appreciated. Code: <!-- Custom shipping form --> <form action="" method="post" name="update_shipping"> <table width="300"> <tr> <td><label> <input <?php if (!(strcmp($_SESSION['shippingmethod'],"1"))) {echo "checked=\"checked\"";} ?> name="grpshipping" type="radio" id="grpshipping_0" value="1" checked="checked" onclick="this.form.submit()"/> Ground Shipping</label></td> <td class="style261"><?php echo date("m/d/Y",$grounddelivery);?></td> <td class="style261">$<?php if(($_SESSION['roundedweight']) >= 21){ echo number_format($row_rsshippingprices['Ground'] + ($row_rsshippingpricesover21['Ground'] * ($varWeightover)) ,2); } else { echo number_format($row_rsshippingprices['Ground'],2); } ?></td> </tr> <?php if($rainbowcart->ConditionalTotal("Quantity", "groundshiponly", "1") == 0) {//show other shipping options ONLY if a ground shipping only item is not in the cart ?> <tr> <td><label> <input <?php if (!(strcmp($_SESSION['shippingmethod'],"2"))) {echo "checked=\"checked\"";} ?> type="radio" name="grpshipping" value="2" id="grpshipping_1" onclick="this.form.submit()" /> Fedex 3 Day</label></td> <td class="style261"><?php echo date("m/d/Y",$fedex3delivery);?></td> <td class="style261">$<?php if(($_SESSION['roundedweight']) >= 21){ echo number_format($row_rsshippingprices['Fedex3'] + ($row_rsshippingpricesover21['Fedex3'] * ($varWeightover)) ,2); } else { echo number_format($row_rsshippingprices['Fedex3'],2); } ?></td> </tr> <tr> <td><label> <input <?php if (!(strcmp($_SESSION['shippingmethod'],"3"))) {echo "checked=\"checked\"";} ?> type="radio" name="grpshipping" value="3" id="grpshipping_2" onclick="this.form.submit()"/> Fedex 2 Day</label></td> <td class="style261"><?php echo date("m/d/Y",$fedex2delivery);?></td> <td class="style261">$<?php if(($_SESSION['roundedweight']) >= 21){ echo number_format($row_rsshippingprices['Fedex2'] + ($row_rsshippingpricesover21['Fedex2'] * ($varWeightover)) ,2); } else { echo number_format($row_rsshippingprices['Fedex2'],2); } ?></td> </tr> <tr> <td><label> <input <?php if (!(strcmp($_SESSION['shippingmethod'],"4"))) {echo "checked=\"checked\"";} ?> type="radio" name="grpshipping" value="4" id="grpshipping_3" onclick="this.form.submit()"/> Next Day PM</label></td> <td class="style261"><?php echo date("m/d/Y",$nddelivery);?></td> <td class="style261">$<?php if(($_SESSION['roundedweight']) >= 21){ echo number_format($row_rsshippingprices['ONPM'] + ($row_rsshippingpricesover21['ONPM'] * ($varWeightover)) ,2); } else { echo number_format($row_rsshippingprices['ONPM'],2); } ?></td> </tr> <tr> <td><label> <input <?php if (!(strcmp($_SESSION['shippingmethod'],"5"))) {echo "checked=\"checked\"";} ?> type="radio" name="grpshipping" value="5" id="grpshipping_4" onclick="this.form.submit()"/> Next Day AM</label></td> <td class="style261"><?php echo date("m/d/Y",$nddelivery);?></td> <td class="style261">$<?php if(($_SESSION['roundedweight']) >= 21){ echo number_format($row_rsshippingprices['ONAM'] + ($row_rsshippingpricesover21['ONAM'] * ($varWeightover)) ,2); } else { echo number_format($row_rsshippingprices['ONAM'],2); } ?></td> </tr> </table> <table class="eC_ButtonWrapper" border="0" cellpadding="0" cellspacing="0"> <tr> <td align="left"><center>Choose an option above and click update to change your shipping preference.<br /><b>PLEASE BE SURE AND PRESS UPDATE IF YOU CHANGE YOUR SHIPPING OPTION<br /><br /><input type="image" name="Update_shipping" id="Update_shipping" value="Update_shipping" alt="Update_shipping" src="WA_eCart/Images/Nautica/Btn4_EN_update.gif" class="eC_ImageButton" /></center></td> </tr> </table> <?php } //end of show if ground ship item is not in the cart?> <?php if($rainbowcart->ConditionalTotal("Quantity", "groundshiponly", "1") <> 0) { ?> <font color="red">The cart contains a Ground Shipping only item, this order can only be shipped ground</font><br /><br /> <?php } ?> </form> <!-- End of Custom shipping form --> How exactly would you validate a form with JavaScript if instead of using the regular input type="submit" to allow submission you used input type="image"?
Hello Wondering something, I created a form and have I have it submit when the user clicks the Submit button. <!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> <title>Assignment 4</title> <style type="text/css"> </style> </head> <body style="color: #009999; background-color: #000000"> <form action="mailto:whatisthematrix01@hotmail.com" name="frmCustomer" method="post"> <table style="width: 85%; height: 222px;"> <tr> <td> <img alt="Space Ship" height="223" src="spaceship_cg2.jpg" style="float: left" width="761" /></td> </tr> </table> <p> </p> <table style="width: 100%"> <tr> <td class="style1">Interstellar Shipping - Customer Registration </td> </tr> </table> <p> </p> <table class="style2"> <tr> <td class="style3"> First Name:</td> <td colspan="2" style="width: 273px"> <input id="Text1" type="text" name="Fname" /></td> </tr> <tr> <td class="style3"> Last Name</td> <td colspan="2" style="width: 273px"> <input id="Text2" type="text" name="Lname" /></td> </tr> <tr> <td class="style3"> City: </td> <td colspan="2" style="width: 273px"> <input id="Text3" type="text" name="UseCity" /></td> </tr> <tr> <td class="style3"> Country:</td> <td colspan="2" style="width: 273px"> <input id="Text4" type="text" name="UserCountry" /></td> </tr> <tr> <td class="style3"> E-Mail:</td> <td colspan="2" style="width: 273px"> <input id="Text6" name="userEmail" type="text" /></td> </tr> <tr> <td class="style3"> Username:</td> <td colspan="2" style="width: 273px"> <input id="Text5" type="text" name="Username" /></td> </tr> <tr> <td class="style3"> Password:</td> <td colspan="2" style="width: 273px"> <input id="Password1" type="password" name="Userpassword" /></td> </tr> <tr> <td class="style3" style="height: 35px"> Gender:</td> <td style="width: 307px; height: 35px;"> Male <input name="radGender" type="radio" value="radMale" /> Female <input name="radGender" type="radio" value="radFemale" /></td> <td style="width: 273px; height: 35px;"> </td> </tr> <tr> <td class="style3"> <input id="Submit1" type="button" value="submit" onclick="doSave()"/></td> <td colspan="2" style="width: 273px"> <input id="Reset1" type="reset" value="reset" /></td> </tr> </table> </form> <script Language = "JavaScript"> function ltrim(varIn) {/*Purpose: Trims the leading spaces from a string*/ var varOut = "" if(!varIn) { // string is null, so nothing to do } else // string has at least one character { for(intI=0; intI < varIn.length; intI++) { if(varIn.charAt(intI) != " ") { //first non-space char found so return //string from this character forward varOut = varIn.substring(intI) break } } } return varOut } function doSave() { var fOk = true var strSuperMessage var superFirstName = document.frmCustomer.Fname var superLastName = document.frmCustomer.Lname var superUserCity = document.frmCustomer.UseCity var superUserName = document.frmCustomer.Username var superUserPassword = document.frmCustomer.Userpassword var superUserEmail = document.frmCustomer.userEmail var checkDigit = /\d/; if ((ltrim(superFirstName.value)).length == 0) { fOk = false strSuperMessage = "First Name Required" superFirstName.focus() } else { if ((ltrim(superLastName.value)).length == 0) { fOk = false strSuperMessage = "Last Name Required" superLastName.focus() } else { if ((ltrim(superUserCity.value)).length == 0) { fOk = false strSuperMessage = "City Required" superUserCity.focus() } else { if ((ltrim(superUserName.value)).length == 0) { fOk = false strSuperMessage = "Username Required" superUserName.focus() } else { if ((ltrim(superUserEmail.value)).length == 0) { fOk = false strSuperMessage = "E-Mail Required" superUserEmail.focus() } else { if (superUserEmail.value.indexOf("@") == -1 || superUserEmail.value.indexOf(".")== -1) { fOk = false strSuperMessage = "The entered e-mail address is not " + "valid.\nE-mail addresses must " + "be in the form name@domain." superUserEmail.focus() } else { if (superUserPassword.value.search(checkDigit) ==-1) { fOk=false strSuperMessage = "Please enter at least one digit in your password field."; superUserPassword.focus() } else { if ((document.frmCustomer.radGender[0].checked==false) && (document.frmCustomer.radGender[1].checked==false)) { fOk = false strSuperMessage = "Gender Required" } } } }}}}} if(fOk) { document.frmCustomer.submit(); //window.location="http://www.google.com" } else alert(strSuperMessage) } </script> </body> </html> Is it okay if I redirect to Google like I did here. if(fOk) { document.frmCustomer.submit(); //window.location="http://www.google.com" } I can't do it in the form action, because I have the mailto link. Simply put, what I did in the if statement, is that okay, there would be no problem with it? Hi, I have a jsp which has a function gets called during the page unload. This jsp has a form with an action attribute to one servlet. Please find below the code snippet. ---- Java script code --- function logoff() { document.forms["FormName"].rel="nofollow" target="_self"; alert('Submitting the form'); document.forms["FormName"].submit(); } --- HTML form code ----- <body onUnload='logOff()'> <form name ="FormName" method="POST" action='<%=sLogoutResponseURL %>'> Whenever the page gets unloaded always logoff function is getting called. I also get the alert message "Submitting the form". But my servrlet does not get invoked. My application supports logging in with the same user id more than once. Scenario it works: User logs in. Close the application. logoff function is called and servlet gets invoked. Scenario it does not work: User logs in one window. Open one more IE window and and open the application with same user id. this can be repeated. Now when i close the application logoff function is called for all of the window close. But servlet does not gets invoked all the time. Sometimes it stops calling servlet. I have searched over the net and found one solution. Below piece of code will make sure form gets always submitted. -------------------------Start ----------------- function fakeSubmit(event) { var target = event ? event.target : this; /* Fire a submit event */ var fakeEvent = $(target).fire("form:submit"); if (fakeEvent.stopped == false) { /* Call the real submit function */ this._submit(); } } if(window.HTMLElement){ /* DOM-compliant Browsers */ HTMLFormElement.prototype._submit = HTMLFormElement.prototype.submit; HTMLFormElement.prototype.submit = fakeSubmit; } else { /* IE does not expose it's HTMLElement object or its children Let the document load so all forms are accounted for */ document.observe("dom:loaded", function(){ for(var i = 0; i < document.forms.length; i ){ document.forms[i]._submit = document.forms[i].submit; document.forms[i].submit = fakeSubmit; } }); } -----------End ------------------ But this resulted in script error while loading the page "object does not support this method or property" at line where document.observe is there. Kindly help at the earliest. Thanks in advance Santosh I have a form with onchange events set on some of the text fields so that calculations can be made. By clicking the Submit button, the form data is then saved to the database. This all works fine as long as you leave a text field by tabbing to or clicking in another field before clicking Submit. However if you make a change in a text field and then directly click the Submit button, the onchange event occurs but the form submission does not. I have tried other types of events such as onfocus, onblur, etc. in place of onchange. I have also tried using the setTimeout function, with various time values, to cause a delay between the onchange and submit events. But the results are the same. Any advice would be appreciated. Thanks.
Hi All, I am new to html and javascript. I am doing a webpage where i need to get the value from a slider and send it across the from client to server side. I need to inform the server side about the value (done) and also update the sliders's value after a submission button. Anyone have any idea how to do the latter part. Here is my code. Code: <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <script type="text/javascript" src="js/range.js"></script> <script type="text/javascript" src="js/timer.js"></script> <script type="text/javascript" src="js/slider.js"></script> </head> <body> <p>Current Value:</p> <div class="slider" id="slider-1" tabIndex="1"> <input class="slider-input" id="slider-input-1"/> </div> <form name="hMess" action="" onsubmit="return convertURL(this);"> <input name="w" type="number" id="h-value" onchange="s.setValue(parseInt(this.value))"> <input name="1" id="1" type="submit" value="Update"></form> <script type="text/javascript"> var s1 = new Slider(document.getElementById("slider-1"), document.getElementById("slider-input-1")); s1.onchange = function () { document.getElementById("h-value1").value = s1.getValue(); }; var a=document.getElementById("h-value1").value s1.setValue(a); var locate = window.location document.hmess.burns.value = locate var text = document.hmess.burns.value function delineate(str) { theleft = str.indexOf("=") + 1; theright = str.indexOf("&"); return(str.substring(theleft, theright)); } </script> body> </html> Thanks in advance. Hi, I'm writing an android application to login into a website by injecting javascript into the HTML. So far it works for inputting the username and password, but I can't enable the submit button. Here is my code Code: "javascript: document.getElementById('user').value = '"+username+"'; document.getElementById('pass').value = '"+password+"'; document.getElementsById('submit').disabled = false;" Here is the code from the website concerning the submission form. Does anybody have any idea why this isn't working? Thank you for any help! Code: <form id="loginForm" name="query" method="post" action="/login/" enctype="application/x-www-form-urlencoded" autocomplete="off"> <p> <input type="hidden" name="one" value="wiscmail.wisc.edu" /> <input type="hidden" name="two" value="WiscMail Login" /> <input type="hidden" name="creds_from_greq" value="1" /> <input type="hidden" name="three" value="1" /> <input type="hidden" name="four" value="a5" /> <input type="hidden" name="five" value="GET" /> <input type="hidden" name="six" value="wiscmail.wisc.edu" /> <input type="hidden" name="seven" value="L2xvZ2lu" /> <input type="hidden" name="relay_url" value="https://wiscmail.wisc.edu/PubCookie.reply" /> <input type="hidden" name="eight" value="YXBwdXJsPXdpc2NtYWlsLndpc2MuZWR1L2xvZ2lu" /> <input type="hidden" name="fr" value="NFR" /> <input type="hidden" name="hostname" value="wiscmail.wisc.edu" /> <input type="hidden" name="nine" value="1" /> <input type="hidden" name="file" value="" /> <input type="hidden" name="flag" value="0" /> <input type="hidden" name="referer" value="(null)" /> <input type="hidden" name="post_stuff" value="" /> <input type="hidden" name="sess_re" value="0" /> <input type="hidden" name="pre_sess_tok" value="1714500944" /> <input type="hidden" name="first_kiss" value="1320154779-954466" /> <input type="hidden" name="pinit" value="0" /> <input type="hidden" name="reply" value="1" /> <input type="hidden" name="create_ts" value="1320154779" /> <label for="user">NetID</label><input type="text" id="user" name="user" size="20" tabindex="1" value="" /> </p> <p class="info"><a tabindex="4" href="/redirect/help-whatisit">What is my NetID?</a> (ie. bbadger)</p> <p><label for="pass">Password</label><input type="password" id="pass" name="pass" tabindex="2" maxlength="36" value="" /> </p> <p class="info"><a tabindex="5" href="/redirect/mynetid-reset">Forgot your password?</a></p> <p><label for="submit" class="invisible">Submit</label><input tabindex="3" class="submitButton" type="submit" id="submit" value="Login" /></p> </form> Is there a way so that I can move the submit button outside of the form tags? and if this is possible, can you make it with multiple text boxes, each with their corresponding submit button? heres the coding Code: <html> <head> <script type="text/javascript"> <!-- function gotoURL() { var newURL = document.url2go.go.value document.location.href=newURL } //--> </script> </head> <body> <form action="javaScript:gotoURL()" method="get" name="url2go"> <input type="text" name="go" value="http://" size="50"> <INPUT TYPE="image" SRC="" id="go" HEIGHT="150" WIDTH="150" BORDER="0" ALT="Submit Form"> </form> </body> </html> |