Click to See Complete Forum and Search --> : update form on the fly


getho
08-11-2003, 12:43 AM
I've just finished a site for a client and they now want to bolt on dynamic sales totals. (urgh). Can someone point me in the right direction for updating a form on the fly. I want to do something like...
Have (eg 3) checkboxes that relate to particular items that update a field. a Totals box at the bottom will show the total of the three fields and that amount will get written to a cookie.

I can do the writing cookie bit.

Help!

Geth

Gollum
08-11-2003, 02:02 AM
you mean sort of like what this does?

<html>
<head>
<script>
function calculate()
{
var t = 0;
if ( document.frm.ch1.checked ) t += 1;
if ( document.frm.ch2.checked ) t += 1000;
if ( document.frm.ch3.checked ) t += 1000000;
document.getElementById('total').innerHTML = t;
}
</script>
</head>
<body>
<form name = "frm">
Option 1, $1<input type=checkbox name=ch1 onclick="calculate();"><br>
Option 2, $1000<input type=checkbox name=ch2 onclick="calculate();"><br>
Option 3, $1000000<input type=checkbox name=ch3 onclick="calculate();"><br>
Total:$<span id=total>0</span>
</form>
</body>
</html>

getho
08-11-2003, 03:53 AM
Sort of? Nay - exaclty.

Gollum, you are precious (how many times have your heard that?!)


Thanks heaps

Geth


ps. Thanks HEAPS!!!