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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

order form script with checkbox radio and drop down menu

Status
Not open for further replies.

TinaBanana

Programmer
May 21, 2002
2
0
0
CA
Hi,
I looked high and low for a script for an order form that uses checkboxes, radio buttons and drop down menu.

couldnt find anything with all 3

id like the total to be displayed as the items are selected and not have to push a button to get the total.

the best i found was a script that uses multiple checkboxes and one set or radio buttons. if i tried to add another set of radio button the script doesnt work.

does anyone know where i can find a script that includes all 3?

thx
 
Maybe something like this will help.
I tried to show an example of each.

<html>
<head>
<script language=&quot;JavaScript&quot;>
var myr1Index = 0;
function myr1_onclick(r1Index)
{
myr1Index = r1Index;
document.form1.r1value.value = document.form1.r1[myr1Index].value;
document.form1.totvalue.value = (parseFloat(document.form1.r1value.value) +
parseFloat(document.form1.c1value.value) +
parseFloat(document.form1.c2value.value) +
parseFloat(document.form1.s1value.value)).toFixed(2);
}

function addemup()
{
if(document.form1.c1.checked == true)
{
document.form1.c1value.value = document.form1.c1.value;
}
else
{
document.form1.c1value.value = &quot;00.00&quot;;
}
if(document.form1.c2.checked == true)
{
document.form1.c2value.value = document.form1.c2.value;
}
else
{
document.form1.c2value.value = &quot;00.00&quot;;
}
document.form1.s1value.value = document.form1.s1.options[document.form1.s1.selectedIndex].value;
document.form1.totvalue.value = (parseFloat(document.form1.r1value.value) +
parseFloat(document.form1.c1value.value) +
parseFloat(document.form1.c2value.value) +
parseFloat(document.form1.s1value.value)).toFixed(2);
}
</script>
</head>
<body onload=&quot;return addemup()&quot;;>
<form name=form1>
<input type=&quot;radio&quot; name=&quot;r1&quot; checked value=&quot;25.99&quot; onclick=&quot;return myr1_onclick(0)&quot;;>
r1 Radio One
<BR>
<input type=&quot;radio&quot; name=&quot;r1&quot; value=&quot;33.99&quot; onclick=&quot;return myr1_onclick(1)&quot;;>
r1 Radio Two
<BR>
<input type=&quot;radio&quot; name=&quot;r1&quot; value=&quot;14.44&quot; onclick=&quot;return myr1_onclick(2)&quot;;>
r1 Radio
<BR>
<input type=&quot;radio&quot; name=&quot;r1&quot; value=&quot;13.33&quot; onclick=&quot;return myr1_onclick(3)&quot;;>
r1 Radio
<input type=&quot;hidden&quot; name=&quot;r1value&quot; value=&quot;25.99&quot;>
<BR>
<HR>
<input type=&quot;checkbox&quot; name=&quot;c1&quot; checked value=&quot;11.11&quot; onchange=&quot;return addemup()&quot;; onclick=&quot;document.form1.c1.blur()&quot;;>
c1 checkbox
<input type=&quot;hidden&quot; name=&quot;c1value&quot;>
<BR>
<input type=&quot;checkbox&quot; name=&quot;c2&quot; value=&quot;12.22&quot; onchange=&quot;return addemup()&quot;; onclick=&quot;document.form1.c2.blur()&quot;;>
c2 checkbox
<input type=&quot;hidden&quot; name=&quot;c2value&quot;>
<BR>
<HR>
<select size=&quot;1&quot; name=&quot;s1&quot; onchange=&quot;return addemup()&quot;;>
<option selected value=&quot;00.00&quot;>Option One</option>
<option value=&quot;9.99&quot;>Option Two</option>
</select>
<input type=&quot;hidden&quot; name=&quot;s1value&quot;>
<HR>
Total:  <input type=&quot;text&quot; name=&quot;totvalue&quot;>
</form>
</body>
</html>


Good luck,

Brian
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top