...

View Full Version : forms - add to total



sandeep89
09-02-2006, 11:27 PM
hi

i have a dropdown menu, and i wanted to know how to add an amount to a total if that item was selected, and if another one was selected then for a total to be altered.

if this was a shop, and then dropdown consisted of products, i want the total to change as a different product is selected.

making the menu wasnt hard, and i tried working with javascript to edit a total but im not sure how, so if anyone can help me to learn how it would be much appreciated

thanks
sandeep

Kravvitz
09-03-2006, 12:13 AM
Perhaps this will give you some ideas: Using Checkboxes to Update a Total (http://www.dynamicsitesolutions.com/javascript/using_checkboxes_to_update_total/)

vwphillips
09-03-2006, 11:37 AM
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">


<head>
<title></title>
<script language="JavaScript" type="text/javascript">
<!--

function AddTo(obj,nme){
obj.form[nme].value=obj.form[nme].value-(obj.last||0);
obj.last=obj.value;
obj.form[nme].value=obj.form[nme].value*1+obj.last*1;
}

//-->
</script>

</head>

<body>
<form>
<select onchange="AddTo(this,'TotalIP');" >
<option value="0" >Option 0</option>
<option value="10" >Option 10</option>
<option value="20" >Option 20</option>
<option value="30" >Option 30</option>
<option value="40" >Option 40</option>
</select>
<br>

<select onchange="AddTo(this,'TotalIP');" >
<option value="0" >Option 0</option>
<option value="12" >Option 12</option>
<option value="22" >Option 22</option>
<option value="32" >Option 32</option>
<option value="42" >Option 42</option>
</select>
<br>

<input type="text" value="0" name="TotalIP" >
</form>
</body>

</html>

sandeep89
09-03-2006, 07:09 PM
cheers thats exactly what i needed



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum