Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sending data from a form without a send button LOL Help!!!!!

Status
Not open for further replies.

1691

MIS
Feb 1, 2005
1
0
0
CA
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>
 
I see just a few small things you'll want to change. First, since you're going to need to know which mailing type the user selects, you'll want to put values in the selection radio buttons. Also, an onClick method could be used to dynamically send the form, but keep in mind that you'll need JavaScript code in there to prevent users from making a second selection, thus doubling the submission.

Also keep in mind that users make mistakes, so having this submit by choosing the radio button may not be the best way to go.

- Rieekan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top