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

please help with this calculate form

Status
Not open for further replies.

fsphp

Technical User
Aug 30, 2001
3
IT
hi I'm trying to set up an order form with total field. difficult is that the fields that have to been added come from different form objects like selection,checkbox and more. visiting forum I've found something that will post. it works only for checkbox fields. if someone could help me I'll be very happy. here the code:
<html>
<head>
<SCRIPT LANGUAGE=&quot;JavaScript&quot;>
function total(){
objForm = document.forms.frmProdForm;
intTotal = 0;
for (i = 0; i < objForm.length; i++) {
if (objForm.elements.type == &quot;checkbox&quot;){
if (objForm.elements.checked){
intTotal += parseInt(objForm.elements.value);
}
}
}
objForm.txtTotalCost.value = intTotal;
}

</script>
</head>

<body>
<form name=&quot;frmProdForm&quot;>
<p>
<select class=form name=Packages size=1>
<option><font face=&quot;Verdana, Arial, Helvetica, sans-serif&quot; size=&quot;2&quot;>Entry
Plan </font></option>
<option><font face=&quot;Verdana, Arial, Helvetica, sans-serif&quot; size=&quot;2&quot;>Basic
Plan</font></option>
<option><font face=&quot;Verdana, Arial, Helvetica, sans-serif&quot; size=&quot;2&quot;>Advanced
Plan</font></option>
<option><font face=&quot;Verdana, Arial, Helvetica, sans-serif&quot; size=&quot;2&quot;>Xtended
Plan</font></option>
<option><font face=&quot;Verdana, Arial, Helvetica, sans-serif&quot; size=&quot;2&quot;>Corporate
Plan</font></option>
</select>
</p>
<p><font
face=&quot;Verdana, Arial, Helvetica, sans-serif&quot; size=1>Frontdesk
<input
name=&quot;Front Page Extensions&quot; type=radio value=Yes>
Yes +50
<input
name=&quot;Front Page Extensions&quot; type=radio value=No>
No </font> </p>
<p>
<input type=&quot;checkbox&quot; NAME=&quot;chkProd1&quot; value=&quot;10&quot; onclick=&quot;total()&quot;>
5 accont more<br>
<input type=&quot;checkbox&quot; NAME=&quot;chkProd2&quot; value=&quot;100&quot; onclick=&quot;total()&quot;>
option b<br>
<input type=&quot;checkbox&quot; NAME=&quot;chkProd3&quot; value=&quot;1000&quot; onclick=&quot;total()&quot;>
opt c<br>
total
<input type=&quot;text&quot; name=&quot;txtTotalCost&quot;>
</p>
</form>
</body>
</html>



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top