JavaScript - Passing Results Of This Sq Ft Converter To A Form.
Similar TutorialsHello, i'm working on a 3 page survey. When hitting next, previous, or submit it passes the values of all the questions to the next page. I've got the whole thing working correcting except for one thing: When the box is "not" checked it passes no value. I'm needing it to have a value of "1" when checked and a value of "0" when not checked, and currently when its not checked and i pass the info it leaves it blank. I'd post the whole code to one of the pages but it's long , so i'll post the snipits of the code. Code: <script type="text/javascript"> /* <![CDATA[ */ function processQueryString() { var formData = location.search; formData = formData.substring(1, formData.length); while (formData.indexOf("+") != -1) { formData = formData.replace("+", " "); } formData = unescape(formData); var formArray = formData.split("&"); for (var i=0; i < formArray.length; ++i) { //document.writeln(formArray[i] + "<br />"); var sDataName = formArray[i].split("=") switch (sDataName[0]) { case ".lib_use": for (var j=0; j < document.getElementsByName(".lib_use").length; ++j) { if (document.getElementsByName(".lib_use").item(j).value == sDataName[1]) { document.getElementsByName(".lib_use").item(j).checked = true; //alert("lib_use set"); } } break; case ".lib_comp": if (sDataName[1] == 1) { document.getElementsByName(".lib_comp").checked = true; document.getElementsByName(".lib_comp").value= 1; } else { document.getElementsByName(".lib_comp").checked = false; document.getElementsByName(".lib_comp").value= 0; } break; default: alert("not caught = " + sDataName[0]); continue; } } } /* ]]> */ </script> <input type="checkbox" name=".lib_comp" id="lib_comp" value="1" /> The first case that i showed in my code is a radio button, and it passes correctly, i just wanted to show the "format" i was using in a working sense. The 2nd case is an example of the check boxes. Thanks for looking at this, and giving any suggestions you might have! hello all, i'm newbie in javascript fucntion. here i got problem to passing the value from child popup form to parent form. here my code parent form Code: <script language="JavaScript"> function selectItem(){ var selindex=document.myForm.myselect.selectedIndex; if (selindex!=0) { document.myForm.item_desc.value=myArray[1]; document.myForm.item_code.value=myArray[0]; } } </script> <form name="myForm" method="post"> <input class="input" type="text" name="item_code" id="item_code" size="30" value ="" /> <input type="button" name="opener" value="Search" class="myButton" onclick="window.open('child_form.php', 'print_view','left=20,top=20,width=750,height=650,toolbar=0,resizable=0,scrollbars=1');return(false);" /> <input class="input" type="text" name="item_desc" id="item_desc" size="80" value ="<?php echo $item_desc?>" /> </form> child_form.php Code: <script language="JavaScript"> function selectItem(){ var selindex=document.popUpForm.myselect.selectedIndex; if (selindex!=0) { window.close(); var myArray = document.popUpForm.myselect[selindex].value.split('*'); window.opener.document.myForm.item_desc.value=myArray[1]; window.opener.document.myForm.item_code.value=myArray[0]; } } </script> <form name="popUpForm"> $i = 0; while ($i < 5){ <input type="image" src="images/plus.png" onclick="selectItem();" name="myselect[]" value=<?php echo $i."*".test;?> width="18" height="18"/> $i++; } </form> Hello, I have 2 things I'm trying to figure out. 1. First form on the page has questions with radio buttons. Each radio's value is a number so a score is assessed at the end. 2. Second form on the page is an email the admin form, which duplicates the score in one field. Question: I would like to know how to write the form results to a text area in second form. However, I can't do this for one, and secondly, the value is a number, can I use labels? Here's the code I've 'made up' so far... JS (i know it's wrong) Code: <script LANGUAGE="JavaScript" type="text/javascript"> function display() { message = "<ul><li><b>Question 1: </b>" + document.quizform.Q1.label; message = "<li><b>Question 2: </b>" + document.quizform.Q2.label; message = "<li><b>Question 3: </b>" + document.quizform.Q3.label; message = "<li><b>Question 4: </b>" + document.quizform.Q4.label; message = "<li><b>Question 5: </b>" + document.quizform.Q5.label; message = "<li><b>Question 6: </b>" + document.quizform.Q6.label + "</ul>"; document.write(message); } </script> Form field example: Code: Question 1:<BR> <label for="Yes"><input type="radio" name="Q1" value="0" checked></label>Yes<br> <label for="No"><input type="radio" name="Q1" value="10"></label>No<br> <label for="I don't know"><input type="radio" name="Q1" value="10"></label>I don't know<br> Hi all, I have a problem about my converter.Why when I'm clicking on the keypad displayed in the form,it doesn't display the result.But when clicking on the keypad on the keyboard,it works?.Plz help me with this trouble.Here are my code. <-html-> <html> <head> <title>Currency Converter</title> <link rel="stylesheet" href="../css/cal.css" type="text/css" > <script type="text/javascript" src="../cal.js"></script> </head> <body> <h2>Currency Converter<h2> <table id="table1"> <form id="currconverter"> <tr> <td>Convert<br>from:</td> <td><input type="text" id="amount" value="" size="17" onChange="convertCurr()"></td> <td> <select id="from_select"> <option value="GBP" selected="selected">Pound Sterling</option> <option value="USD">US Dollar</option> <option value="MUR">Mauritian RS</option> <option value="EUR">Euro</option> <option value="JPY">Yen</option> </select> </td> </tr> <tr> <td>Convert<br>to:</td> <td><input type="text" id="result" value="" size="17" readonly="readonly" onchange="convertCurr();"></td> <td> <select id="to_select"> <option value="GBP">Pound Sterling</option> <option value="USD">US Dollar</option> <option value="MUR" selected="selected">Mauritian RS</option> <option value="EUR">Euro</option> <option value="JPY">Yen</option> </select> </td> </tr> </form> </table> <br> <table cellpadding="0" cellspacing="5" border="1" align="center" bgcolor="AABBCC"> <form name="cal"> <tr> <td><input type="button" value="7" onClick="currconverter.amount.value += '7'"></td> <td><input type="button" value="8" onClick="currconverter.amount.value += '8'"></td> <td><input type="button" value="9" onClick="currconverter.amount.value += '9'"></td> </tr> <tr> <td><input type="button" value="4" onClick="currconverter.amount.value += '4'"></td> <td><input type="button" value="5" onClick="currconverter.amount.value += '5'"></td> <td><input type="button" value="6" onClick="currconverter.amount.value += '6'"></td> </tr> <tr> <td><input type="button" value="1" onClick="currconverter.amount.value += '1'"></td> <td><input type="button" value="2" onClick="currconverter.amount.value += '2'"></td> <td><input type="button" value="3" onClick="currconverter.amount.value += '3'"></td> </tr> <tr> <td><input type="button" value="0" onClick="currconverter.amount.value += '0'"></td> <td><input type="button" value="." onClick="currconverter.amount.value += '.'"></td> <td><input type="reset" value="C" OnClick="currconverter.amount.value = ''"></td> </tr> </form> </table> </body> </html> <-javascript-> function convertCurr() { var amount = parseFloat(document.getElementById("amount").value); var form = document.getElementById("currConverter"); var fromSelect = document.getElementById("from_select"); var toSelect = document.getElementById("to_select"); var result= document.getElementById("result"); var currencyTo = []; switch (fromSelect.value) { case "GBP": currencyTo = [1, 1.61, 46.91, 1.23, 128.89]; break; case "USD": currencyTo = [1.62, 1, 28.90, 0.76, 79.84]; break; case "MUR": currencyTo = [1.02, 0.03, 1, 0.03, 0.00]; break; case "EUR": currencyTo = [0.81, 1.31, 38.01, 1, 104.47]; break; case "JPY": currencyTo = [0.01, 1.25, 0.00, 0.96, 1]; break; default: alert("It broke."); } result.value = (amount * currencyTo[toSelect.selectedIndex]).toFixed(2); } Hello, I've been reading my JS book, have done a 'Degrees Converter' which converts fahrenheit into centigrade. There is a prompt box which automatically loads when the website is loaded. I am pressuming this is because I have my script in the body. I have a question if anybody could possibly help me out. How do I get my script as a link? To explain a little better, I wanted to put the words 'Degrees Converter' onto my page(as a link), so that when people click the link, it loads up the prompt box. I'm very new to JavaScript, so if anyone could help me out it would be a great help. Thank you very much. Hi I have the following currency converter code which works fine, but I need to make it possible for someone else to edit the euro price using a visual editor such as contribute. 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>Untitled Document</title> <script language='javascript'> exchRate = 1.13; function getUKP(price) { document.write('(£' + Math.round(price / exchRate) + ')'); } </script> </head> <body> <strong>€526</strong> <script type="text/javascript">getUKP('526');</script><br /><br /> <strong>€1999</strong> <script type="text/javascript">getUKP('1999');</script> </body> </html> This code requires someone to change the figure in the javascript as well as the html. I guess I need to somehow automatically pick up the numeric characters only from the html which appear on the same line of code... or perhaps there's an easier way.? Any help would be much appreciated. Thanks Hello, I am having trouble with a javascript length converter that I got from http://www.javascriptkit.com/script/...onverter.shtml It is working fine in dreamweaver, but when it goes live on my site, the calculations do nothing. I can see everything in the drop down menus, but when i click the "to" button, nothing happens. I got the following errors from chrome when activating any of the calculation functions. I'm wondering if anyone here can help me decipher these 1. Uncaught TypeError: Cannot read property 'from_unit' of undefined 1. convert_unitDefault.aspx:459 2. (anonymous function)Default.aspx:482 3. onchangeDefault.aspx:483 1. Default.aspx:459Uncaught TypeError: Cannot read property 'from_unit' of undefined 1. convert_unitDefault.aspx:459 2. (anonymous function)Default.aspx:496 3. onchangeDefault.aspx:497 1. Default.aspx:459Uncaught TypeError: Cannot read property 'from_unit' of undefined 1. convert_unitDefault.aspx:459 2. (anonymous function)Default.aspx:516 3. onclickDefault.aspx:517 Hey guys. I am in an introductory computer science class and I am having trouble writing JavaScript code for a currency converter. I can get it to where it spits out numbers, but its always the same numbers. I think there's something wrong in the calculations part of my code but I can't figure it out. I am posting it below, and any help would be greatly appreciated. Thank you. <html> <head> <title>CURRENCY CONVERTER</title> <script language="JavaScript"> function converting() { with (document.conversions) { if (unit[1].selected) { var result = eval(unit.value*0.974); convertedValue.value = result; } // end if if (unit[2].selected) { var result = eval(unit[2].value*0.492); convertedValue.value = result; } // end if if (unit[3].selected) { var result = eval(unit[3].value*0.706); convertedValue.value = result; } // end if } // end with } // end function converting </script> </head> <form name = "conversions"> <table border=6 bgcolor ="yellow"> <tr> <td><font color="red" size=6>Enter amount in U.S. $:</font></td> <td><input type="text" name="inUnit" size = 4></td> </tr> <tr> <td><font color="red" size=6>Select target unit:</font> <td><select name="unit"> <option value="Select Currency" selected>Choose one... <option value="1">Canadian Dollars <option value="2">British Pounds <option value="3">Euros </select> <td><input type="button" value="Convert" onclick="converting()"> </tr> <tr> <td><font color="green" size=6>Converted Value:</font> <td><input type="text" name="convertedValue" size = 4> <td><input type="reset" value="Reset"> </tr> </table> </form> </body> </html> Hi all -- I realize this is probably pretty simple, but it's been a while since I did any Javascripting, and things have changed a great deal. My apologies if I sound a bit clueless. I need to create a conversion tool. On one side of the tool are 4 form boxes. On the other, just text (not in form boxes). Under the covers, I have formulas for converting the numbers -- mostly basic math functions. So, the user types in numbers, clicks convert and the text changes. For some reason, I'm having a hard time getting this to go. How can I get the results of these calculations to show up as text within a DIV tag and not inside a form element? There are lots of examples of getting these calculations to appear within form boxes, but not within DIVs. Any examples would be greatly appreciated. This page is already using the Dojo toolkit for some other functionality, is this something I could leverage here to build my Javascript? Thanks in advance for your patience. Hello all. I'm so glad i found this forum!!! This looks like a great coding community. This will be my First Post. I was wondering if you guys can help me with my weight converter. I cant seem to make it work properly on my site. here is the code im using: <p class="about">Convert weight measurements between U.S./Imperial and SI (Metric) units<br /> Type your value in a box, click the <input onclick="alert('Not this button!')" type="button" name="test_bt" value="Go!" /> and all unit conversions in the same category will be calculated.</p> <form action=""> <table width="500" border="1" cellspacing="0" cellpadding="4"> <tbody> <tr bgcolor="#0066ff"><th class="headings" colspan="3" bgcolor="#1765BB">SI (Metric)</th></tr> <tr bgcolor="#0066ff"> <td class="headings" bgcolor="#103e78" width="288">Tonne</td> <td class="headings" align="right" bgcolor="#103e78" width="130"><input type="text" name="mTon" size="15" /></td> <td class="headings" bgcolor="#103e78" width="57"><input onclick="if (checkNum(mTon.value)) compute(this.form,mTon.name,weight_data)" type="button" name="mTon_bt" value="Go!" /></td> </tr> <tr bgcolor="#0066ff"> <td class="headings" bgcolor="#103e78" width="288">Kilogram (kg)</td> <td class="headings" align="right" bgcolor="#103e78" width="130"><input type="text" name="mKilogram" size="15" /></td> <td class="headings" bgcolor="#103e78" width="57"><input onclick="if (checkNum(mKilogram.value)) compute(this.form,mKilogram.name,weight_data)" type="button" name="mKilogram_bt" value="Go!" /></td> </tr> <tr bgcolor="#0066ff"> <td class="headings" bgcolor="#103e78" width="288">Gram (g)</td> <td class="headings" align="right" bgcolor="#103e78" width="130"><input type="text" name="mGram" size="15" /></td> <td class="headings" bgcolor="#103e78" width="57"><input onclick="if (checkNum(mGram.value)) compute(this.form,mGram.name,weight_data)" type="button" name="mGram_bt" value="Go!" /></td> </tr> <tr bgcolor="#0066ff"> <td class="headings" bgcolor="#103e78" width="288">Milligram (mg)</td> <td class="headings" align="right" bgcolor="#103e78" width="130"><input type="text" name="mMilligram" size="15" /></td> <td class="headings" bgcolor="#103e78" width="57"><input onclick="if (checkNum(mMilligram.value)) compute(this.form,mMilligram.name,weight_data)" type="button" name="mMilligram_bt" value="Go!" /></td> </tr> <tr><th class="headings" colspan="3" bgcolor="#103e78"> </th></tr> <tr bgcolor="#0066ff"><th class="headings" colspan="3" bgcolor="#1765BB">Troy weight</th></tr> <tr bgcolor="#0066ff"> <td class="headings" bgcolor="#103e78" width="288">Pound (lb t)</td> <td class="headings" align="right" bgcolor="#103e78" width="130"><input type="text" name="troyPound" size="15" /></td> <td class="headings" bgcolor="#103e78" width="57"><input onclick="if (checkNum(troyPound.value)) compute(this.form,troyPound.name,weight_data)" type="button" name="troyPound_bt" value="Go!" /></td> </tr> <tr bgcolor="#0066ff"> <td class="headings" bgcolor="#103e78" width="288">Ounce (oz t)</td> <td class="headings" align="right" bgcolor="#103e78" width="130"><input type="text" name="troyOunce" size="15" /></td> <td class="headings" bgcolor="#103e78" width="57"><input onclick="if (checkNum(troyOunce.value)) compute(this.form,troyOunce.name,weight_data)" type="button" name="troyOunce_bt" value="Go!" /></td> </tr> <tr bgcolor="#0066ff"> <td class="headings" bgcolor="#103e78" width="288">PennyWeight (dwt)</td> <td class="headings" align="right" bgcolor="#103e78" width="130"><input type="text" name="troyDWT" size="15" /></td> <td class="headings" bgcolor="#103e78" width="57"><input onclick="if (checkNum(troyDWT.value)) compute(this.form,troyDWT.name,weight_data)" type="button" name="troyDWT_bt" value="Go!" /></td> </tr> <tr bgcolor="#0066ff"> <td class="headings" bgcolor="#103e78" width="288">Grain<br /> Same as Avoirdupois grain</td> <td class="headings" align="right" bgcolor="#103e78" width="130"><input type="text" name="troyGrain" size="15" /></td> <td class="headings" bgcolor="#103e78" width="57"><input onclick="if (checkNum(troyGrain.value)) compute(this.form,troyGrain.name,weight_data)" type="button" name="troyGrain_bt" value="Go!" /></td> </tr> <tr bgcolor="#6699ff"> <td class="headings" colspan="3" bgcolor="#103e78"> </td> </tr> <tr bgcolor="#0066ff"><th class="headings" colspan="3" bgcolor="#1765BB">Avoirdupois weight</th></tr> <tr bgcolor="#0066ff"> <td class="headings" bgcolor="#103e78">British ("long") ton</td> <td class="headings" align="right" bgcolor="#103e78"><input type="text" name="briTon" size="15" /></td> <td class="headings" bgcolor="#103e78"><input onclick="if (checkNum(briTon.value)) compute(this.form,briTon.name,weight_data)" type="button" name="briTon_bt" value="Go!" /></td> </tr> <tr bgcolor="#0066ff"> <td class="headings" bgcolor="#103e78">US ("short") ton</td> <td class="headings" align="right" bgcolor="#103e78"><input type="text" name="usTon" size="15" /></td> <td class="headings" bgcolor="#103e78"><input onclick="if (checkNum(usTon.value)) compute(this.form,usTon.name,weight_data)" type="button" name="usTon_bt" value="Go!" /></td> </tr> <tr bgcolor="#0066ff"> <td class="headings" bgcolor="#103e78" height="42">British ("long") hundredweight (cwt)</td> <td class="headings" align="right" bgcolor="#103e78" height="42"><input type="text" name="briCWT" size="15" /></td> <td class="headings" bgcolor="#103e78" height="42"><input onclick="if (checkNum(briCWT.value)) compute(this.form,briCWT.name,weight_data)" type="button" name="briCWT_bt" value="Go!" /></td> </tr> <tr bgcolor="#0066ff"> <td class="headings" bgcolor="#103e78">US ("short") hundredweight (cwt)</td> <td class="headings" align="right" bgcolor="#103e78"><input type="text" name="usCWT" size="15" /></td> <td class="headings" bgcolor="#103e78"><input onclick="if (checkNum(usCWT.value)) compute(this.form,usCWT.name,weight_data)" type="button" name="usCWT_bt" value="Go!" /></td> </tr> <tr bgcolor="#0066ff"> <td class="headings" bgcolor="#103e78">Stone</td> <td class="headings" align="right" bgcolor="#103e78"><input type="text" name="briStone" size="15" /></td> <td class="headings" bgcolor="#103e78"><input onclick="if (checkNum(briStone.value)) compute(this.form,briStone.name,weight_data)" type="button" name="briStone_bt" value="Go!" /></td> </tr> <tr bgcolor="#0066ff"> <td class="headings" bgcolor="#103e78">Pound (lb)</td> <td class="headings" align="right" bgcolor="#103e78"><input type="text" name="avdpPound" size="15" /></td> <td class="headings" bgcolor="#103e78"><input onclick="if (checkNum(avdpPound.value)) compute(this.form,avdpPound.name,weight_data)" type="button" name="avdpPound_bt" value="Go!" /></td> </tr> <tr bgcolor="#0066ff"> <td class="headings" bgcolor="#103e78">Ounce (oz)</td> <td class="headings" align="right" bgcolor="#103e78"><input type="text" name="avdpOunce" size="15" /></td> <td class="headings" bgcolor="#103e78"><input onclick="if (checkNum(avdpOunce.value)) compute(this.form,avdpOunce.name,weight_data)" type="button" name="avdpOunce_bt" value="Go!" /></td> </tr> <tr bgcolor="#0066ff"> <td class="headings" bgcolor="#103e78">Dram (dr)</td> <td class="headings" align="right" bgcolor="#103e78"><input type="text" name="avdpDram" size="15" /></td> <td class="headings" bgcolor="#103e78"><input onclick="if (checkNum(avdpDram.value)) compute(this.form,avdpDram.name,weight_data)" type="button" name="avdpDram_bt" value="Go!" /></td> </tr> <tr bgcolor="#0066ff"> <td class="headings" bgcolor="#103e78">Grain</td> <td class="headings" align="right" bgcolor="#103e78"><input type="text" name="avdpGrain" size="15" /></td> <td class="headings" bgcolor="#103e78"><input onclick="if (checkNum(avdpGrain.value)) compute(this.form,avdpGrain.name,weight_data)" type="button" name="avdpGrain_bt" value="Go!" /></td> </tr> <tr bgcolor="#0066ff"> <td class="headings" colspan="2" align="center" bgcolor="#103e78"><input onclick="resetAll(this.form)" type="button" name="res7" value="Clear all numbers" /></td> <td class="headings" bgcolor="#103e78"> </td> </tr> </tbody> </table> <p> </p> </form> <p> </p> and help will be greatly appreciated. Hi, I need to create a currency converter using a drop down menu. Firstly i needed to do a regular expressions check to make sure only numerics are entered and I got that. The one thing im pretty confused on is how to do the calculations in the actual function. Ive popped the code below, and if anyone could give me some hints on how to get the data from the drop down menu and calculate it properly that would be awesome. Thanks. -oh and i know all my coding is here but i think its relevent that you can view it all. Code: <html> <head> <style type ="text/css"> @import url(style.css); </style> <script type="text/javascript"> function convert() { var OK = true; var inDollar= document.getElementById('dollars').value; var regex= /^\d{1,}$/; if (!regex.test(inDollar)) { OK=false; alert('Australian Dollars must be entered as numeric with no decimal places'); } return OK; var rate= country.conversion.value; if (document.getElementByID('conversion').selectedIndex == 0) { var rate= country.conversion.value; var convert = inDollar*rate; alert('$'+inDollar+' converts to'+rate+' US Dollars'); } if (document.getElementByID('conversion').selectedIndex == 1) { var rate= country.conversion.value; var convert = inDollar*rate; alert('$'+inDollar+' converts to'+rate+' Euro'); } if (document.getElementByID('conversion').selectedIndex == 2) { var rate= country.conversion.value; var convert = inDollar*rate; alert('$'+inDollar+' converts to'+rate+' Yuan'); } if (document.getElementByID('conversion').selectedIndex == 3) { var rate= country.conversion.value; var convert = inDollar*rate; alert('$'+inDollar+' converts to'+rate+' Yen'); } } </script> </head> <body> <h1>Currency Page</h1> <form> Australian Dollars:<input type="text" name="dollars" id="dollars" /> <br /> Convert to: <select id='conversion' name='country'> <option value=".73">US Dollars</option> <option value=".62">Euro</option> <option value="5.8">Chinese Yuan</option> <option value="78.5">Japanese Yen</option> </select> <br /> <input type="button" value="Convert" onClick="convert()" /> </form> </body> </html> I can only seem to find really complicated ones online, nothing simple which i think this is. Thanks I am trying to make a unit converter with two dropdown boxes, two textfields and a button. I want to enter a number into the first textfield, select a unit option, then select another appropriate unit option based on the first selection, press the button and get the result in the second textfield. What would be the best approach for this. So far I have: <html> <head> <script type="text/javascript"> function convertUnit () { // convert pound to kilogram document.unitForm.toField.value = document.unitForm.fromField.value / 2.2; // convert kilogram to pound document.unitForm.toField.value = document.unitForm.fromField.value * 2.2; // convert inch to centimeter document.unitForm.toField.value = document.unitForm.fromField.value / 2.54; // convert centimeter to inch document.unitForm.toField.value = document.unitForm.fromField.value * 2.54; } </script> </head> <body style="background-color:lightgray"> <form action="" name="unitForm"> <input type="text" name="fromField" onfocus="this.form.fromField.value=''; style.background='lightyellow';" onblur="style.background='white';" /> <select name="fromList" > <option value="" selected="selected">Unit</option> <option id="fromPound" value="2.2">lb</option> <option id="fromKilogram" value="1.0">kg</option> <option id="fromInch" value="1.0">in</option> <option id="fromCentimeter" value="2.54">cm</option> </select> <input type="button" value="Convert" onclick="convertUnit()" /> <input type="text" name="toField" readonly="readonly" /> <select name="toList"> <option value="" selected="selected">Unit</option> <option name="toKilogram" id="toKilogram" value="1.0">kg</option> <option name="toPound" id="toPound" value="2.2">lb</option> <option name="toCentimeter" id="toCentimeter" value="2.54">cm</option> <option name="toInch" id="toInch" value="1.0">in</option> </select> <input type="reset" value="Reset" /> </form> </body> </html> Hi, I am quite new to javascript but I'm quite sure this problem is very easy to solve. I have a vague idea of what might be going wrong but I have no idea what I should be doing instead. Here is what I'm trying to do: User inputs X and Y coordinates into form validate that they are numbers do a little bit of maths redirect to a php script with a single variable tacked onto the end of the url Here is the form code: Code: //part of a larger php script to make the form echo "<form name='gotoForm' onsubmit='return coordCalc()'> <fieldset> <legend>Go to Square</legend> X <input type='text' id='X' size='1' maxlength='3'/> Y <input type='text' id='Y' size='1' maxlength='3'/> <input type='submit' value='Go To' /> </fieldset> </form> "; which references these functions in the header: Code: //Is it a number function isNumeric(elem, helperMsg){ var numericExpression = /^[0-9]+$/; if(elem.value.match(numericExpression)){ return true; }else{ alert(helperMsg); elem.focus(); return false; } } //deal with the input, check if they are both numbers with the above function //if they are do some maths on the input //add the result onto a url and redirect function coordCalc (){ var Xcoord = document.getElementById('X'); var Ycoord = document.getElementById('Y'); if(isNumeric(Xcoord, "Please enter a Number for X")){ if(isNumeric(Ycoord, "Please enter a Number for Y")){ //Takes the X and Y coordinates and transforms them into a single number //not fully coded in case you try putting some numbers into the formula btw :) var X = parseInt(document.getElementById('X').value); var Y = parseInt(document.getElementById('Y').value); var G = 16; var Z = (((G + 1) - Y) - Y); var A = (Y + Z); var B = (X - 1); var L = ((A * (G - 1)) + B); window.location = "map.php?start=" + L; } } return false; } The number validation works but the url ends up as map.php?start=NaN. Now, this simply must be the way I am assigning the Xcoord and Ycoord variables with the document.getElementByID() function I am sure. But like I said, I have no idea what to do instead, any help is massively appreciated. Thankyou! I need to style a checkbox, so I made it into two images behind a form with hidden inputs. On click the form takes input from the other form into the hidden fields and POSTs it. Then I use PHP to grab that POST and put it back into the original form. Here are some snippets of what I am trying to do: First form input: PHP Code: <input type="text" name="email" id="email1" value="<?php if(isset($_POST['email2'])) { echo $_POST['email2']; } ?>" style="height:25px;width:270px;" /> Second form input: PHP Code: <input type="hidden" name="email2" id="email2" /> Second form submit image button: PHP Code: <input type="image" src="img/Boxchecked.jpg" value="submit" onclick="fname2.value = fname1.value; lname2.value = lname1.value; email2.value = email1.value" width="20" height="20" /> The forms work fantastic on everything but IE, which does not save the field values. How do I fix the onclick event to save them in IE? Help is much appreciated. I inherited a calculator form using javascript that passes the form field data to a "lead mailbox" .asp page on a different site, and that site would then email/forward the salesman the data. The calculator also passes the calculated data to the next page for the user and gives them their calculated loan range. What I would like to do is not send this data to the "lead mailbox" site but instead send the data via Gmail (if possible) to the salesman as he wants to generate leads outside the company and not use the "lead mailbox". There are two lines of code that specify where to send the data (to the "lead mailbox" site) but I don't know how the receiving page is setup to receive the form data fields as it is https: (SSL) and I don't have access to that code. Everything works perfect with the code...I just want to send the data to a new location...but not sure how or if I can pass the data fields to a Gmail account like the salesman would like. Thanks for any help you can provide!! Normally sending form data is easy...but I inherited this and it was custom written javascript. Code: {document.contact.action = "https://www.othersitemailbox.com/post.aspx?account=EXN01&source=PTPPC-QQ"; document.contact.landing.value = "http://www.best-mortgage-programs.com/QQ.html?"+link} I have "blurred/changed" out the actual landing page value and actual URL of the https: address for privacy reasons... Thanks!! hi there, i'm new here and pretty new to js. i'm making a page for my daughter's school - or trying to. they are having a silent auction and i'm trying to make a very simple bidding page. where i'm running into problems is passing the bid to a text box (read only) where it can be updated when a new bid is entered. I would like this to be in the upper part of the page with the listings of the auction items, i just can't wrap my head around how to do this. I've gotten as far as the form for entering the bod and contact info. I have the php code to submit. i still have to get the validation js to make it more secure. thanks for any help. Code: <html> <body> <h1 id="logo"></h1> <div id="main"> <p> <h4>Silent Auction</h4> <form name="auction" method="post" action="send_form_email.php" > <label for="item1">Item 1</label> <br /> <label for="curr_bid_item_1">Current Bid = </label><br /> Your Bid = <input type="text" name="item1" maxlength="15" size="10" /> <br /> <br /> <label for="item2">Item 2</label><br /> <label for="curr_bid_item_2">Current Bid = </label><br /> Your Bid = <input type="text" name="item2" maxlength=="15" size="10" /> <br /> <br /> <label for="item3">Item 3</label><br /> <label for="curr_bid_item_3">Current Bid = </label><br /> Your Bid = <input type="text" name="item3" maxlength="15" size="10" /> <br /> <br /><br /><br /> <form name="contactform" method="post" action="send_form_email.php" onsubmit="document.getElementById('myButton').disabled=true; document.getElementById('myButton').value='Submitting, please wait...';"> <label for="first_name">First Name *</label> <input type="text" name="first_name" maxlength="50" size="30"><br /><br /> <label for="last_name">Last Name *</label> <input type="text" name="last_name" maxlength="50" size="30"><br /><br /> <label for="email">Email Address *</label> <input type="text" name="email" maxlength="80" size="30"><br /><br /> <label for="telephone">Telephone Number</label> <input type="text" name="telephone" maxlength="30" size="30"><br /><br /> <label for="comments">Comments</label><br /> <textarea name="comments" maxlength="1000" cols="40" rows="6"></textarea><br /><br /> <input type="submit" value="Submit" id="myButton" /> </form> </form> </div> </body> </html> Fixed.
Hi I'm putting together the following website, HGV/LGV Training and have an issue regarding a form submit action. Basically I've used an open-source script for the search form so can't get any support from the Author. My problem is that I need the search results to appear in a different URL but at the moment they just appear in a new DIV on the home page. My knowledge of JS is limited and can't get my head around what the OS script is doing. I think the relevant section of the search form is as follows: <form method=post action=<?echo $_PHP_SELF;?>> <input type="text" name="zipcode"> <? echo show_country_codes(); ?> Any help on this would be greatly appreciated. Keith. Hi all, I am new to JS and usually learn by studying code posted online and modify it to have it do what I need. Recently, I used a totaling plugin for an online ordering form which does the below: item1 qty(user input text) * preset price = total price item2 qty(user input text) * preset price = total price item3 qty(user input text) * preset price = total price -------------------------------------------------------- grand total -------------------------------------------------------- The JS code which passes the grandTotal variable is as below: Code: function ($this){ // sum the total of the $("[id^=total_item]") selector var sum = $this.sum(); $("#grandTotal").text( // round the results to 2 digits "₹" + sum.toFixed(2) ); } The problem I have is the above grandTotal displays the final value when put into a table like below: Code: <td align="right" id="grandTotal"></td> But I am unable to make it work by passing it into a variable within the form fields. I would like to do something like this: Code: <input type="text" name="grandTotal" id="grandTotal" readonly="readonly" /> Can somebody please help me fix this? Any help will be greatly appreciated. Thank you. I have a "pre-order" opt-in page disguised as a "step 1" in the order process of a clickbank product I'm ready to launch. I'm wanting to pass the user's first name, last name, and email address (built into the optin form) over to the clickbank order page upon submit. Clickbank gives me the data strings you can pass along, but I'm not sure how to properly configure this function or where to place it in my page code. This is the only step I have remaining before I can go live, and it's holding me back. Any suggestions would be extremely helpful. I can provide any code needed for review to assist in getting this wrapped up. Thanks in advance |