JavaScript - Javascript To Preselect Form Criteria
Hi there,
I'm very very new to programming and I think what I'm after is possible but I'm not 100% sure. Here it goes: I've got a search form in my website that is corresponds to a external searchable database - Caspio. The site is Wordpress and the search form is deployed via a url wrapped inside the Caspio plugin shortcode. I'd like to create some javascript to pre-select elements in the search form. I want to be able to do this externally from Caspio because I want to set up 20-30 of these pre-sorted searches. This will make it easier for clients to access the most popular searches. I've tried to research how to do this but I haven't been able to find very much - perhaps I'm using the wrong words. Any help would be much appreciated! Many thanks Similar TutorialsI'm sure this is a simple one. I have a results page, pulled from a mysql database using _GET variables from a form. On this page is a second form to refine the results by reloading the page. I want each form element item to remember/prepopulate with what it's related $_get variable is.
Hello. I have what I think is a simple request, but I'm not quite sure how to go about it. I hope you can help me! Problem: I am building an online store and need to restrict checkout unless a customer has bought at least $20 worth of items. If they have >$20, they can check out. If they have <$20, they should get an error when they click the checkout button that explains that there is a $20 minimum. I don't want them to be able to checkout, so maybe I also need to disable the button or hide it? Here are the two elements in my HTML: The total price div: Code: <div id="totalprice">{tag_productgrandtotal}</div> The checkout button: Code: {tag_buybutton,<img alt="" src="/CatalystImages/shop_checkout.png" />} Here is what I've tried to put together with my bare minimum knowledge of Javascript: Code: <body onload="checkOut()"> <script type="text/javascript"> function checkOut() { var tp = document.getElementById('totalprice').innerHTML; tp = tp.replace(/[^0-9$\.]/g,""); // strip anything except numbers decimals and $ sign if (tp < "$20.00") { ???????????????? } else { ????????????????? } } </script> I'm not sure the top part is correct, and where I've put "?????" I have no idea what to do to deactivate the checkout button and produce the error message. Thank you SO much for any help you can provide. Hey, I have extracted a single criteria from an XML file before and the output in a table by using the: Code: 'for each.. in ....' document.write("<td>+colour+"<td>"); How would I extract data from an XML file (chocolates) when two criteria from a drop down are selected (price and type) For example, if in the XML file there are 50p, 75p, 20p, 65p for the price and white, milk, dark for the type, how would I do this so that these are shown in the drop down and if the user selects 50p and milk for instance, than mars appears, as this is the correct combination to match? I would like the output in a table, so using the; document.write("<table border='2'>"); .............................. document.write("</tr>"); document.write("</table>"); Thanks Hi, I'm trying to build up a multi-select filter with checkboxes. I found few good scripts but I've got a problem to adapt them.. The script below can filter results based on criteria (that you can select via checkboxes). The results displayed are checked or unchecked boxes. What I want is : display results with div (for ex:<div>result1</div>) and not checkbox. How can I do that? Code: <script type="text/javascript" src="js/jquery.js.css"></script> <script type="text/javascript"> $(function() { $('#search input:checkbox').click(function() { var classes = $('#search input:checkbox:checked'). map(function() { return $(this).val(); }).get().join('.'); classes = (classes ? '.' : '') + classes; $('#results input:checkbox').attr('checked', false). filter(classes).attr('checked', true); }); }); </script> </head> <body> <div id="search"> <fieldset> <label><input type="checkbox" value="animal"> Animal</label> <label><input type="checkbox" value="vegetable"> Vegetable</label> </fieldset> <fieldset> <label><input type="checkbox" value="small"> Small</label> <label><input type="checkbox" value="large"> Large</label> </fieldset> </div> <div id="results"> <p><input type="checkbox" class="small animal"> Cat</p> <p><input type="checkbox" class="medium animal"> Tiger</p> <p><input type="checkbox" class="large animal"> Elephant</p> <p><input type="checkbox" class="small vegetable"> Pea</p> <p><input type="checkbox" class="large vegetable"> Pumpkin</p> </div> </ul> </body> </html> Thanks for your help I'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 guys, Been stuck for a few days with this scenario. Any help? The alert box appears on an error. But the submitting won't stop. The details are submitted and the form is processed. Any help is greatly appreciated... Code: <html> <head> <script type="text/javascript" src="email_helper/jscripts/tiny_mce/tiny_mce.js"></script> <script type="text/javascript"> tinyMCE.init({ // General options mode : "textareas", theme : "simple" }); </script> <script language="javascript"> function MM_openBrWindow(theURL,winName,features) { window.open(theURL,winName,features); } function err_check(){ var email = document.getElementById('to_email').value; if(email.length==0){ alert('Please Enter Email Address'); return false; } var AtPos = email.indexOf("@") var StopPos = email.lastIndexOf(".") if (AtPos == -1 || StopPos == -1) { alert("Please Enter Valid Email Address"); document.getElementById('email').focus(); return false; } email = document.getElementById('cc_email').value; if(email.length != 0){ var AtPos = email.indexOf("@") var StopPos = email.lastIndexOf(".") if (AtPos == -1 || StopPos == -1) { alert("Please Enter Valid Email Address"); document.getElementById('email').focus(); return false; } } var answer = confirm ("Send E-Mail?"); if (!answer){ return false; } } </script> <!-- /TinyMCE --> <style type="text/css"> body, table, td, th{ background-color:#CCCCCC; font-family: Arial; font-size:14px; } .que{ font-weight:bold; } </style> </head> <body> <form method="post" enctype="multipart/form-data"> <?php include 'library/database.php'; include 'library/opendb.php'; $query = mysql_query("SELECT email,contact,mobile FROM users WHERE user_id='$uid'") or die(mysql_error()); $row = mysql_fetch_row($query); $from_email = $row[0]; $from_person = $row[1]; $from_mobile = $row[2]; $query = mysql_query("SELECT customer_id FROM campaign_summary WHERE camp_id='$camp_id'") or die(mysql_error()); $row = mysql_fetch_row($query); $cusid = $row[0]; $query = mysql_query("SELECT email FROM client_info WHERE comp_id='$cusid'") or die(mysql_error()); $row = mysql_fetch_row($query); $toer = $row[0]; include 'library/closedb.php'; ?> <table width="100%" border="0"> <tr><td rowspan="4"><input type="submit" name="send_email" id="send_email" style="height:50px; width:100px;" value="SEND" onClick="return err_check();" /></td><td><span class="que">From : </span></td><td colspan="3"><?php echo $from_email; ?><input type="hidden" name="from_mail" id="from_mail" /><input type="hidden" name="camp_id" id="camp_id" value="<?php echo $camp_id;?>"/></td></tr> <tr><td><span class="que">To : </span></td><td colspan="3"><input name="to_email" id="to_email" style="width:250px;" value="<?php echo $toer;?>"/></td></tr> <tr><td><span class="que">CC : </span></td><td colspan="3"><input name="cc_email" id="cc_email" style="width:250px;"/></td></tr> <tr><td><span class="que">Subject : </span></td><td colspan="3"><input style="width:300px;" name="subject" id="subject" /></td></tr> <tr><td rowspan="1" colspan="2"> </td><td><input type="checkbox" name="ori_pdf" id="ori_pdf" checked /> PDF Quotation</td><td> </td><td> </td></tr><tr><td colspan="2"><span class="que">Credit Application</span></td><td><input type="checkbox" name="corporate" id="corporate"/>Corporate</td><td><input type="checkbox" name="individual" id="individual" />Individual</td><td><input type="checkbox" name="cash" id="cash" />Cash Account</td> </tr> <tr> <td colspan="2" rowspan="3"></td><td><input type="checkbox" name="tabloid" id="tabloid" />Tabloid Example</td> <td><input type="checkbox" name="broadsheet" id="broadsheet" />Broadsheet Example</td></tr> <tr><td><input type="checkbox" name="colmt" id="colmt" />Column Sizes Tabloid</td> <td><input type="checkbox" name="colmb" id="colmb" />Column Sizes Broadsheet</td></tr> <tr><td><input type="checkbox" name="maps" id="maps" />Maps / Distribution</td><td colspan="2" align="right">External Attachments <input id="upload_file" name="upload_file" type="file"/> </td></tr> <tr><td colspan="2"><span class="que">Message :</span></td><td colspan="3"> <textarea id="elm1" name="elm1" rows="15" cols="80" style="width: 100%"> <?php echo "<br><br><br>" . $from_person . "<br>" . $from_mobile; ?> </textarea> </td></tr> </table> </form> </body> </html> I'm a long time lurker on here just barely created an account to ask this question. I work at a call center, and we use different webapps to fill out tickets. One I've used for a long time allows dynamically updating forms with javascript. I have a whole bunch of bookmarked javascript injections like: Code: javascript:if((top.detail.findObj('X31').value="Inquiry")!=""); That code will fill out most everything in that ticket, leaving me to fill in the details. I have one of those for all of the most common tickets, and can create and finish a ticket in less than 30 seconds when it takes others 3-4 minutes. I recently switched to a different system and I'm having trouble with my code. I'm a noob at javascript for sure, but I'm not new to programming. Anyway any pointers would be nice. The system we use doesn't allow me to see the source... I'm not sure how to explain it. It loads everything in a frame. In chrome I can right click then inspect element and get the ID but it the above javascript doesn't work. Examples: Old app source ex: Code: <label for="X31">Category:</label> was all i needed new app(before the body code is just code for the login form, etc): Code: <body onLoad="startit()" onUnload="stopit()"> </body> <div align="center" valign="center" id="LoadMessageID" style="position: relative; top:40%; color:#0069A5; font-size:100% ;"> <img src="/arsys/shared/images/Progress_NonModal-circle.gif" alt="wait image"/> Loading... </div> </html> formloader: Code: <form name="form1" action="/arsys/forms/bmcitsm/HPD:Incident+Management+Console/Default+User+View+(Support)/?cacheid=a22a36a8" method="post"> example of inspect element in chrome (something i want to change with javascript injection): Code: <input id="arid301602600" type="text" class="text " style="top:0; left:0; width:225; height:21;" readonly=""> Is there a way to make it so JavaScript can pre-set a FORM value? Something like this: Code: <?php $country = $_SESSION['country']; ?> <SCRIPT type="text/javascript"> function SomeFunctionForm() { document.forms["form"]["country"].value=="<?php echo $country; ?>) { } } </SCRIPT> <FORM> <SELECT name="country"> <OPTION>Afghanistan</OPTION> <OPTION>Albania</OPTION> <OPTION>Algeria</OPTION> </SELECT> </FORM> I can't just drop the PHP Code: <?php $country = $_SESSION['country']; ?> into the SELECT value because it will brake the alphabetical listing, which is why I am wondering if JavaScript can do it this way, as this way wouldn't brake the alphabetical listing? I have the following form function goto(form) { var index=form.select.selectedIndex if (form.select.options[index].value != "0") { location=form.select.options[index].value;}} //--> </script> </p> <form name="form1"> <p><select onchange="goto(this.form)" name="select" style="font-size: 10pt;"> <option>----- Choose Wholesaler ------ </option><option value="travl.com.au/social-passport-profiles.html">A1 Classic Holidays </option><option value="web_development.htm">AAT Kings </option><option value="html_codes.htm">Abercrombie & Kent </option><option value="html_codes_chart.htm">Adventure Associates </option><option value="javascript_codes.htm">Adventure Destinations </option><option value="index.htm">Adventure World </option><option value="web_development.htm">African Wildlife Safaris </option><option value="html_codes.htm">Albatross Travel Group </option><option value="html_codes_chart.htm">Amazing Vacations </option><option value="javascript_codes.htm">Asiaquest Tours </option><option value="216_color_chart.htm">ATI Tours </option><option value="index.htm">Australian Pacific Tours </option><option value="web_development.htm">Beachcomber Tours </option><option value="html_codes.htm">Bench International </option><option value="html_codes_chart.htm">Bentours </option><option value="javascript_codes.htm">Beyond Travel Group </option><option value="216_color_chart.htm">Broome & The Kimberley Holidays </option><option value="index.htm">Bunnik Tours </option><option value="web_development.htm">Cathay Pacific Holidays </option><option value="html_codes.htm">CBT Holidays </option><option value="html_codes_chart.htm">Chat Tours </option><option value="javascript_codes.htm">CIT Holidays </option><option value="216_color_chart.htm">Club Med Australia </option><option value="216_color_chart.htm">Contiki Holidays for 18-35's </option><option value="216_color_chart.htm">Contours Travel </option><option value="index.htm">Cosmos </option><option value="web_development.htm">Creative Holidays </option><option value="html_codes.htm">Destination Canada </option><option value="html_codes_chart.htm">Eastern Europe Travel </option><option value="javascript_codes.htm">Elegant Resorts & Villas </option><option value="216_color_chart.htm">Explore Holidays </option><option value="index.htm">Freestyle Holidays </option><option value="web_development.htm">French Travel Connection </option><option value="html_codes.htm">Garuda Orient Holidays </option><option value="html_codes_chart.htm">Global Getaway </option><option value="javascript_codes.htm">Globus </option><option value="216_color_chart.htm">Go See Touring </option><option value="216_color_chart.htm">Greece & Mediterranean Travel </option><option value="216_color_chart.htm">Handpicked Holidays </option><option value="index.htm">Helen Wong's Tours </option><option value="web_development.htm">HIS Travel </option><option value="html_codes.htm">Holidays On Location </option><option value="html_codes_chart.htm">Honeymoon Worldwide Holidays </option><option value="javascript_codes.htm">Ibertours </option><option value="216_color_chart.htm">Icon Holidays </option><option value="index.htm">Inca Tours </option><option value="web_development.htm">Insight Vacations </option><option value="html_codes.htm">Intrepid Travel </option><option value="html_codes_chart.htm">Japan Experience Tours </option><option value="javascript_codes.htm">JTB Australia </option><option value="216_color_chart.htm">Kumuka Worldwide </option><option value="216_color_chart.htm">Made Easy Tours </option><option value="216_color_chart.htm">Nordic Travel </option><option value="index.htm">Northern Gateway </option><option value="web_development.htm">Orient Pacific Holidays </option><option value="html_codes.htm">Peregrine Adventures </option><option value="html_codes_chart.htm">Qantas Holidays </option><option value="javascript_codes.htm">Rosie Holidays </option><option value="216_color_chart.htm">Royal Orchid Holidays </option><option value="index.htm">Sachi Tours </option><option value="web_development.htm">Scenic Tours </option><option value="html_codes.htm">Selective Tours </option><option value="html_codes_chart.htm">Singapore Airlines Holidays </option><option value="javascript_codes.htm">Southern Italian Tours </option><option value="216_color_chart.htm">Sportsnet Holidays </option><option value="216_color_chart.htm">Sun Island Tours </option><option value="216_color_chart.htm">Sundowners Overland </option><option value="index.htm">Talpacific Holidays </option><option value="web_development.htm">Tasmania's Temptation Holidays </option><option value="html_codes.htm">Tempo Holidays </option><option value="html_codes_chart.htm">Temptation Tours </option><option value="javascript_codes.htm">Territory Discoveries </option><option value="216_color_chart.htm">The Imaginative Traveller </option><option value="index.htm">Trafalgar Tours </option><option value="web_development.htm">Travel IndoChina </option><option value="html_codes.htm">Travel Makers </option><option value="html_codes_chart.htm">United Vacations </option><option value="javascript_codes.htm">Venture Holidays </option><option value="216_color_chart.htm">Wendy Wu Tours </option><option value="216_color_chart.htm">Wildlife Safari Australia </option></select> </p></form> and i would like to make some of the option values auto redirect to an external website address. It seems this form code I have only allows for page redirects within my own website. I would be grateful if anybody could assist with how I can make some changes to this form to allow me to do this. Thank you in advance. Hi there I have created a php form (which i inserted into wordpress site) www.lookinside.co.za/wp - under "Conferences" tab... This form is working well, I just have a couple of changes which I would like to make, and am not sure how. if someone could perhaps maybe even help with one of the items on here I would be extremely grateful please :-) Changes: 1. is it possible to have a "print" button to appear on the page that comes up after submitting the quote? 2. Can we insert a "date" field possibly with a calendar popup to select a date for the conference? 3. Can images and other text appear on the "after submission" page? that will then also print, ie: info about the conference rooms, images? 4. Can the no. of people box be shorter in length? (the outline of the box) 5. when the submitted form is emailed through / and viewed, is it possible to include the title of the duration? ie at the moment it shows as: "Duration: R200", can we make it "Duration: Full Day - R200" or something? THe same for the "menu selection" php: PHP Code: <?php if(isset($_POST['action']) && $_POST['action'] == "submit_post"): ?> <?php $string = "Customer Name: ". $_POST['name']. "\n"; $string .= "Company: ". $_POST['company']. "\n"; $string .= "Conference Name: ". $_POST['field-36b58f8c5142ff3']. "\n"; $string .= "Telephone Number: ". $_POST['field-7c496d0fb21abfd']. "\n"; $string .= "Duration: ". $_POST['field-385963a5c9a4ef9']. "\n"; $string .= "Number of People: ". $_POST['field-5af722f60ee2f9b']. "\n"; $string .= "Menu: ". $_POST['menu']. "\n"; $string .= "Overhead Projector: ". $_POST['field-73cf21adf8b52d5']. "\n"; $string .= "Email: ". $_POST['field-3f92f5a7876cd50']. "\n"; $string .= "Sub Total: ". $_POST['totalcost']. "\n"; print "<p>". nl2br($string) ."</p>"; $to = $_POST['field-3f92f5a7876cd50'] . ", "; //This is the users email address $to .= "melissafleetwood@yahoo.com" . ", "; //Put your first email here $to .= "melissa@run-time.co.za"; //Put your second email here $subject = "Reciept confirmation"; $headers = "From: melissa@lookinside.co.za"; mail($to, $subject, $string, $headers); ?> <?php else: ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <title>Contact Form Test</title> </head> <body> <form action="" method="post"> <div> <input type="hidden" name="action" id="acctid" value="submit_post" /> </div> <table cellspacing="5" cellpadding="5" border="0"> <td valign="top"> <strong>Name of Contact Person:</strong> </td> <td valign="top"> <input type="text" name="name" id="name" size="40" value="" /> </td> </tr> <tr> <td valign="top"> <strong>Company:</strong> </td> <td valign="top"> <input type="text" name="company" id="company" size="40" value="" /> </td> </tr> <tr> <td valign="top"> <strong>Official Name Of Conference</strong> </td> <td valign="top"> <input type="text" name="field-36b58f8c5142ff3" id="field-36b58f8c5142ff3" size="40" value="" /> </td> </tr> <tr> <td valign="top"> <strong>Tel No Of Contact Person:</strong> </td> <td valign="top"> <input type="text" name="field-7c496d0fb21abfd" id="field-7c496d0fb21abfd" size="40" value="" /> </td> </tr> <tr> <td valign="top"> <strong>Duration:</strong> </td> <td valign="top"> <input type="radio" name="field-385963a5c9a4ef9" id="game4" value="220.00" onclick="UpdateCost()"> Full Day R220.00<br/> <input type="radio" name="field-385963a5c9a4ef9" id="game5" value="200.00" onclick="UpdateCost()"> Half Day R200.00<br/> </td> </tr> <tr> <td valign="top"> <strong>No Of People</strong> </td> <td valign="top"> <input type="text" name="field-5af722f60ee2f9b" id="field-5af722f60ee2f9b" size="40" value="" onchange="UpdateCost()"/> </td> </tr> <tr> <td valign="top"> <strong>Please select a menu:</strong> </td> <td valign="top"> <input type="radio" name="menu" id='game0' value="60.00" onclick="UpdateCost()">Menu A (60.00)<br> <input type="radio" name="menu" id='game1' value="90.00" onclick="UpdateCost()">Menu B (90.00)<br> <input type="radio" name="menu" id='game2' value="120.00" onclick="UpdateCost()">Menu C (120.00)<br> <input type="radio" name="menu" id='game3' value="150.00" onclick="UpdateCost()">Braai/Barbeque (150.00)<br> </td> </tr> <tr> <td valign="top"> <strong>Overhead Projector</strong> </td> <td valign="top"> <input type="checkbox" name="field-73cf21adf8b52d5" id="game6" value="650.00" onclick="UpdateCost()">R650.00 <br/> </td> </tr> <tr> <td valign="top"> <strong>Email of Contact Person: </strong> </td> <td valign="top"> <input type="text" name="field-3f92f5a7876cd50" id="field-3f92f5a7876cd50" size="40" value="" /> </td> <tr> <td valign="top"> <strong>Sub Total: </strong> </td> <td valigh="top"> <input type="text" id="totalcost" name="totalcost" size="40" value=""> </td> <tr> <td colspan="2" align="center"> <input type="submit" value=" Submit Form " /> </td> </tr> </form> JAVASCRIPT Code: <script type="text/javascript"> function UpdateCost() { var sum = 0; var gn, elem, totalAmmount, peopleNum; for (i=0; i<7; i++) { gn = 'game'+i; if(gn != 'game6'){ elem = document.getElementById(gn); if (elem.checked == true) { sum += Number(elem.value); } } peopleNum = document.getElementById('field-5af722f60ee2f9b').value; if(isNaN(peopleNum ) || peopleNum==''){ totalAmmount = sum; } else{ totalAmmount = sum * peopleNum; } } if(document.getElementById('game6').checked == true) { totalAmmount += Number(document.getElementById('game6').value); } document.getElementById('totalcost').value = totalAmmount.toFixed(2); } </script> <script type="text/javascript"> var value=""; var numPeople=document.getElementById("field-5af722f60ee2f9b") numPeople.onkeydown=function(e){ value = this.value + e; } numPeople.onkeyup=function(e) { this.value=this.value.replace(/[^\d]/,''); if(this.value != value) { UpdateCost(); } } </script> </body> </html> <?php endif; ?> Javascript: /* This script and many more are available free online at The JavaScript Source!! http://javascript.internet.com Created by: Jay Rumsey | http://www.nova.edu/~rumsey/ */ function UpdateCost() { var sum = 0; var gn, elem, totalAmmount, peopleNum; for (i=0; i<7; i++) { gn = 'game'+i; if(gn != 'game6'){ elem = document.getElementById(gn); if (elem.checked == true) { sum += Number(elem.value); } } peopleNum = document.getElementById('field-5af722f60ee2f9b').value; if(isNaN(peopleNum ) || peopleNum==''){ totalAmmount = sum; } else{ totalAmmount = sum * peopleNum; } } if(document.getElementById('game6').checked == true) { totalAmmount += Number(document.getElementById('game6').value); } document.getElementById('totalcost').value = totalAmmount.toFixed(2); } Thank you so much Hi i need help with an assignment that validates forms using javascript. Using my instructors example as a guide, i wrote this if you click submit on the example it properly returns false and displays an error message, in my assignment it does nothing but submit to the echo while im trying to get an error message. The assignment is unfinished but i wanted to test out the first bit of code and its not working. I have a form which shows additional text boxes when certain fields in a drop down box are selected. I have this working, but what I am trying to do is have the javascript keep the additional text boxes viewable after the form is submitted via php POST when there is an error. It displays the error(Example: Please enter your name), the drop down field that the user chooses stays selected, but the text boxes aren't there unless you click off of the current selection and back on it. Does this make any sense? I've been having a hard time with this and was hoping someone here would take a little pity and render me a great service. I'm using a javascript to get the user's timezone and am trying to pass the response to an input field in a php form. With a great deal of trial and error I got a demo working to a point but I'm stuck. Here's what works now: Code: <p id="timezoneInformation" style="text-align: center;">click here</p> <script src="jstz.js"></script> <script> var container = document.getElementById("timezoneInformation"); var showTimezone = function () {container.textContent = jstz.determine().name();}; container.addEventListener("click", showTimezone); </script> jstz.js is from Automatic timezone detection using JavaScript The example above is as far as I've gotten. I would like to send the results to a form field to submit to the server. It's probably a lot easier than I'm making it out, but I've had little success and would welcome any help. Thank you. Hi I am trying to create a form with radio buttons, when an option is selected and submitted it comes up with a message but i cant get it working. If anyone can help that would be greatly appreciated. If the first radio button is selected I want the message class 1 and if the second class 2 etc Code: <?xml version="1.0" encoding="utf-8"?> <head><title>Car Insurance</title><script language="javascript" type="text/javascript"> <!-- function get_radio_value() { for (var i=0; i < document.insuranceform.insurance.length; i++) { if (document.insuranceform.insurance[i].checked) { var rad_val = document.insuranceform.insurance[i].value; } } } --> </script> </head> <body> <form name="insuranceform"> Please select an option<br> <input type="radio" name="insurance" value="Class 1" checked="checked"> Age is 30 or above and married<br> <input type="radio" name="insurance" value="Class 2"> Age is 30 or above and single<br> <input type="radio" name="insurance" value="Class 3"> Age is below 30 and married<br> <input type="radio" name="insurance" value="Class 4"> Age is below 30 and single<br> <input type="submit" onclick="get_radio_value()"> </form> </body> </html> Hiya, Ive been getting a form together that tallies billable parts for a service call. Each line has a quantity and a price and a subtotal. I have a grand total at the bottom that sums the subtotals. Everything is working fine, but I have a combo box that chooses whether the subtotal should zero out the field. So I would select Yes/No in the dropdown and it should change the subtotal to zero. That part is not working. Im using the following code which works without the Yes/No dropdown. Code: var L1 = "Cost.0"; var L2 = "Quantity.0"; var sum = 0; sum = this.getField(L1).value * this.getField(L2).value; f = this.getField("SubPrice0"); f.value = sum; This is what I am trying and cant get to work Code: var L1 = "Cost.0"; var L2 = "Quantity.0"; var sum = 0; sum = this.getField(L1).value * this.getField(L2).value; if (this.getField("Bill0") = "Yes") { f = this.getField("SubPrice0"); f.value = sum; } else { f = this.getField("SubPrice0"); f.value = 0; } Output in the combo box is Yes/No respectively. Any help would be appreciated. Sorry, its probably an easy thing that Im missing. Hi, I'm trying to create a dynamic form using Javascript. This form essentially needs to collect data through certain fields and populate another. Code: <input name="Field1" type="text" /> <input name="Field2" type="text" /> <input name="Field3" type="text" /> <input name="Field4" type="text" /> <input name="Field5" type="text" /> Field 6 value = answer I'm stuck on how to go about this. I'm assuming I need to create multiple conditions to check each field and then output to a text box? Code: if ((document.thisform.Field1.value == null) && (document.thisform.Field2.value == null)) { I've done a bit of searching around but can't find anything with particular reference to this exact requirement, only brick level functions. If I have left anything out, or if it's all amiss, please let me know. I'm a real Newbie, I've just started with coding html and css. Need javascript that does the following: 1. In a "Submit" form a customer adds a password and username that I've preassigned 2.Clicking on "Submit" causes the script to read the pass and username and see that it's correct. If correct it then triggers another form to appear which was hidden by CSS. Is this possible? How? Thanks for any help. T. I have a problem finding Form in javascript. document.getElementById('MyForm'); return "HTMLUnknownElement". But if I add a dummy form previous for the one I actually want to find, then: document.getElementById('DummyForm'); returns "HTMLUnknownElement", and then document.getElementById('MyForm'); Returns "HTMLFormElement", that is what need. But this unknown element, the dummy form creates a lot of other problems with my site so this solution is no good for me. Why cant I find my Form? Thanks. Hello, I am using the following javascript to validate a text field on my site: Code: function checkExpire(form) { // regular expression to match required date format re = /^\d{1,2}\/\d{1,2}\/\d{4}$/; if(form.txtExpire.value != '' && !form.txtExpire.value.match(re)) { alert("Invalid date format: " + form.txtExpire.value); form.txtExpire.focus(); return false; } return true; } The above code works fine for the following situations: The default value of the field is: __/__/____ The JavaScript code above will not accept that for a field value. If a user inputs the following for a date 5_/7_/11__ for May 7th, 2011 the JavaScript will not accept the format it must be entered as: 05/07/2011 (in order to clear the validation)... NOW HERE IS WHAT I NEED THE JAVASCRIPT TO DO: 1) It needs to accept __/__/____ as a value that can be inserted into the database 2) still retains the code above so 5_/7_/11__ is not an acceptable date but 05/07/2011 will work just fine 3) Now... the default value of the text field in Internet Explorer is __/__/____ but the value is blank in Mozilla Firefox so in an instance where the text field is completely blank I need the JavaScript to assign the value '__/__/____' ... SO FAR: I did at one point get both the validation working so it worked for rules 1 and 2 mentioned above but I completely destroyed it while trying to integrate rule 3 into the functionality. So I know this can be accomplished with a series of if / else statements as well as assigning a value to a form object to handle rule# 3 ... I am just a novice getting ready to turn intermediate in JavaScript so any help, guidance, reference or example / sample code you could give me would be much appreciated. Thank your for your assitance and I hope you are all doing well. Cordially, aRK |