I'm using an order form where clients may update quantity in a text field.
To make it more customers friendly, I would like to have the field with the select format.
But doing so in the form, the javascript is not doing anymore.
Can anyone have a look and let me know what to change in the script to have it working with select fields in place of the text fields?
Thank you
To make it more customers friendly, I would like to have the field with the select format.
But doing so in the form, the javascript is not doing anymore.
Can anyone have a look and let me know what to change in the script to have it working with select fields in place of the text fields?
Thank you
Code:
<html> <head> <title>My Untitled Document</title> <script type="text/javascript" language="javascript"> <!-- function calcVals() { var form = document.form1; var total = document.getElementById("valTotal"); var currentTotal = total.value.replace('$',''); // document.pgCartOrder.calculatedTotal.value='0'; var tempTotal = 0; var totalFields = eval(form.elements.length-1); //alert (totalFields); for (i=0; i < totalFields; i++) { if(form.elements[i].type == 'submit'){ }else if(form.elements[i].type == 'text'){ if(form.elements[i].value > 0){ tempTotal = tempTotal + parseFloat(form.elements[i].title * parseInt(form.elements[i].value)); }else if(form.elements[i].value = 'NaN'){ form.elements[i].value = ""; } } } if (String(total) != 'NaN') { form.valTotal.value = "$"+ tempTotal; } else { form.valTotal.value = 'ERROR'; } } form.valTotal.value = round(form.valTotal.value, 2); --> </script> </head> <body onload="calcVals()"> <? if ($_POST['send']){ ?> <? echo floor($_POST['textfield']) ;?> <? echo "<br>";?> <? echo floor($_POST['textfield1']) ;?> <? echo "<br>";?> <? echo floor($_POST['textfield2']) ;?> <? echo "<br>";?> <? } ?> <form id="form1" name="form1" method="post" action="" > $ 9.25<input type="text" name="textfield" value="1" title="9.25" onkeyup="calcVals();"/><br/> $12.25<input type="text" name="textfield1" title="12.25" onkeyup="calcVals();"/><br/> $ 5.00<input type="text" name="textfield2" title="-5.00" onkeyup="calcVals();"/><br/> <input type="text" readonly="" name="valTotal" id="valTotal" value="$0"/> <input type="submit" name="send" value="SEND" /> </form> </body> </html>
Comment