Funny but that's the way it's created (try the form) but now!...I need to have this form act out a couple of more functions. Right now the form on the spot calculations. Without any buttons. Very well done by tektip programmers ;-)
Looking to go a litle further with this form.
Is there a few snippets of code that I can use to
act out the following:
1. I need the user to select option and be able to continue with an order process.
2. Have the data from the form redirect to an order page. The user fills in all the required fields. and sends it through cgi and to my email(for now) or a payment gateway(when it's set up). Please help me get this form into motion.
any suggestions? Here is my form below
---------------
<script language="JavaScript">
function calculate(){
theForm = document.shipForm
theWeight = isNaN(parseInt(theForm.weight.value)) ? 0 : parseInt(theForm.weight.value)
theDist = isNaN(parseInt(theForm.dist.value)) ? 1 : parseInt(theForm.dist.value)
weightCharge = 0
if (theWeight > 50){
weightCharge = (parseInt((theWeight-1)/50)) * 2.85
}
distCharge = .93 * theDist
for (x=1; x<=3; x++){
theRow = document.getElementById("row" + x)
theRow.childNodes[2].innerHTML = dollars(weightCharge)
theRow.childNodes[3].innerHTML = dollars(distCharge)
switch (x){
case 1:
base = 10.88
break;
case 2:
base = 14.52
break;
case 3:
base = 19.08
break;
}
theRow.childNodes[4].firstChild.value = dollars(base + weightCharge + distCharge)
}
theForm.weight.value = theWeight
theForm.dist.value = theDist
}
function dollars(inVal){
inVal = Math.ceil(inVal*100)/100
str = "$" + inVal
switch (str.length - str.indexOf(".")){
case 2:
str = str + "0"
break;
case 3:
if (str.indexOf(".") == -1) str = str + ".00"
break;
default:
str = str + ".00"
break
}
return str
}
</script>
</head>
<body>
<form name="shipForm">
<table border="1" cellspacing="0">
<tbody>
<tr>
<th>Type</th>
<th>Base</th>
<th>Weight <br>
<input name="weight" onblur="calculate()"></th>
<th>Distance <br>
<input name="dist" onblur="calculate()"></th>
<th>Total</th>
<th>Select</th>
</tr>
<tr id="row1"><td>Express</td><td>$10.88</td><td>$0.00</td><td>$0.93</td><td><input name="ttl1" readonly></td><td><input type=radio name="selection" checked></td></tr>
<tr id="row2"><td>Rush</td><td>$14.52</td><td>$0.00</td><td>$0.93</td><td><input name="ttl2" readonly></td><td><input type=radio name="selection"></td></tr>
<tr id="row3"><td>Priorty</td><td>$19.08</td><td>$0.00</td><td>$0.93</td><td><input name="ttl3" readonly></td><td><input type=radio name="selection"></td></tr>
</tbody>
</table>
</form>
Looking to go a litle further with this form.
Is there a few snippets of code that I can use to
act out the following:
1. I need the user to select option and be able to continue with an order process.
2. Have the data from the form redirect to an order page. The user fills in all the required fields. and sends it through cgi and to my email(for now) or a payment gateway(when it's set up). Please help me get this form into motion.
any suggestions? Here is my form below
---------------
<script language="JavaScript">
function calculate(){
theForm = document.shipForm
theWeight = isNaN(parseInt(theForm.weight.value)) ? 0 : parseInt(theForm.weight.value)
theDist = isNaN(parseInt(theForm.dist.value)) ? 1 : parseInt(theForm.dist.value)
weightCharge = 0
if (theWeight > 50){
weightCharge = (parseInt((theWeight-1)/50)) * 2.85
}
distCharge = .93 * theDist
for (x=1; x<=3; x++){
theRow = document.getElementById("row" + x)
theRow.childNodes[2].innerHTML = dollars(weightCharge)
theRow.childNodes[3].innerHTML = dollars(distCharge)
switch (x){
case 1:
base = 10.88
break;
case 2:
base = 14.52
break;
case 3:
base = 19.08
break;
}
theRow.childNodes[4].firstChild.value = dollars(base + weightCharge + distCharge)
}
theForm.weight.value = theWeight
theForm.dist.value = theDist
}
function dollars(inVal){
inVal = Math.ceil(inVal*100)/100
str = "$" + inVal
switch (str.length - str.indexOf(".")){
case 2:
str = str + "0"
break;
case 3:
if (str.indexOf(".") == -1) str = str + ".00"
break;
default:
str = str + ".00"
break
}
return str
}
</script>
</head>
<body>
<form name="shipForm">
<table border="1" cellspacing="0">
<tbody>
<tr>
<th>Type</th>
<th>Base</th>
<th>Weight <br>
<input name="weight" onblur="calculate()"></th>
<th>Distance <br>
<input name="dist" onblur="calculate()"></th>
<th>Total</th>
<th>Select</th>
</tr>
<tr id="row1"><td>Express</td><td>$10.88</td><td>$0.00</td><td>$0.93</td><td><input name="ttl1" readonly></td><td><input type=radio name="selection" checked></td></tr>
<tr id="row2"><td>Rush</td><td>$14.52</td><td>$0.00</td><td>$0.93</td><td><input name="ttl2" readonly></td><td><input type=radio name="selection"></td></tr>
<tr id="row3"><td>Priorty</td><td>$19.08</td><td>$0.00</td><td>$0.93</td><td><input name="ttl3" readonly></td><td><input type=radio name="selection"></td></tr>
</tbody>
</table>
</form>