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="JavaScript">
function total(){
objForm = document.forms.frmProdForm;
intTotal = 0;
for (i = 0; i < objForm.length; i++) {
if (objForm.elements.type == "checkbox"{
if (objForm.elements.checked){
intTotal += parseInt(objForm.elements.value);
}
}
}
objForm.txtTotalCost.value = intTotal;
}
</script>
</head>
<body>
<form name="frmProdForm">
<p>
<select class=form name=Packages size=1>
<option><font face="Verdana, Arial, Helvetica, sans-serif" size="2">Entry
Plan </font></option>
<option><font face="Verdana, Arial, Helvetica, sans-serif" size="2">Basic
Plan</font></option>
<option><font face="Verdana, Arial, Helvetica, sans-serif" size="2">Advanced
Plan</font></option>
<option><font face="Verdana, Arial, Helvetica, sans-serif" size="2">Xtended
Plan</font></option>
<option><font face="Verdana, Arial, Helvetica, sans-serif" size="2">Corporate
Plan</font></option>
</select>
</p>
<p><font
face="Verdana, Arial, Helvetica, sans-serif" size=1>Frontdesk
<input
name="Front Page Extensions" type=radio value=Yes>
Yes +50
<input
name="Front Page Extensions" type=radio value=No>
No </font> </p>
<p>
<input type="checkbox" NAME="chkProd1" value="10" onclick="total()">
5 accont more<br>
<input type="checkbox" NAME="chkProd2" value="100" onclick="total()">
option b<br>
<input type="checkbox" NAME="chkProd3" value="1000" onclick="total()">
opt c<br>
total
<input type="text" name="txtTotalCost">
</p>
</form>
</body>
</html>
<html>
<head>
<SCRIPT LANGUAGE="JavaScript">
function total(){
objForm = document.forms.frmProdForm;
intTotal = 0;
for (i = 0; i < objForm.length; i++) {
if (objForm.elements.type == "checkbox"{
if (objForm.elements.checked){
intTotal += parseInt(objForm.elements.value);
}
}
}
objForm.txtTotalCost.value = intTotal;
}
</script>
</head>
<body>
<form name="frmProdForm">
<p>
<select class=form name=Packages size=1>
<option><font face="Verdana, Arial, Helvetica, sans-serif" size="2">Entry
Plan </font></option>
<option><font face="Verdana, Arial, Helvetica, sans-serif" size="2">Basic
Plan</font></option>
<option><font face="Verdana, Arial, Helvetica, sans-serif" size="2">Advanced
Plan</font></option>
<option><font face="Verdana, Arial, Helvetica, sans-serif" size="2">Xtended
Plan</font></option>
<option><font face="Verdana, Arial, Helvetica, sans-serif" size="2">Corporate
Plan</font></option>
</select>
</p>
<p><font
face="Verdana, Arial, Helvetica, sans-serif" size=1>Frontdesk
<input
name="Front Page Extensions" type=radio value=Yes>
Yes +50
<input
name="Front Page Extensions" type=radio value=No>
No </font> </p>
<p>
<input type="checkbox" NAME="chkProd1" value="10" onclick="total()">
5 accont more<br>
<input type="checkbox" NAME="chkProd2" value="100" onclick="total()">
option b<br>
<input type="checkbox" NAME="chkProd3" value="1000" onclick="total()">
opt c<br>
total
<input type="text" name="txtTotalCost">
</p>
</form>
</body>
</html>