i would do a full total count on every refresh so you never need to
subtract.
remember and do server side validation tho :)
--
dc
[Todays Threads]
[This Message]
[Subscription]
[Fast Unsubscribe]
[User Settings]
[Donations and Support]
I can use an onclick to add the count however you can keep clicking on
the radio button to increment it.
onchange only takes effect when you click off of something.
I suppose I could reverse the values.. give the 1 a value of -1 and
the 0 a value of 1.
Or is it best to loop through the form
so you'd loop through the form fields each time?
On Tue, 31 Aug 2004 11:14:11 -0500, Greg Morphis [EMAIL PROTECTED] wrote:
I can use an onclick to add the count however you can keep clicking on
the radio button to increment it.
onchange only takes effect when you click off of something.
I
If you want the price displayed on the page and updated every time a new option is selected w/o the page being reloaded you need to use _javascript_, otherwise i would imagine the radio button's value would be associated with a price from the database. (optionid 12 = $50)
[Todays Threads]
[This
Yeah, count from zero by looping thro the form and totalling every time
that there is an onclick.Then just write that total out in the
apprpriate place.
Means that you don't need to bother about keeping track of the state of
the form, means that you are only worried about the current state of
this is what I have
function showValues(theForm) {
currVal = document.getElementById(ptotal);
sum = 0;
for(i=0;itheForm.elements.length - 1;i++) {
sum +=parseInt(theForm.elements[i].value);
}
alert(sum);
}
Unfortunately the radios have a value of 0 and a value of 1.
So this adds up 0 + 1 per
I did away with the damn radios and went with select boxes..
that solved the headache! thanks!
On Tue, 31 Aug 2004 17:39:51 +0100, [EMAIL PROTECTED]
[EMAIL PROTECTED] wrote:
Yeah, count from zero by looping thro the form and totalling every time
that there is an onclick.Then just write that
: Greg Morphis [mailto:[EMAIL PROTECTED]
Sent: 31 August 2004 18:34
To: CF-Talk
Subject: Re: SOT : Keeping JS Count
this is what I have
function showValues(theForm) {
currVal = document.getElementById(ptotal);
sum = 0;
for(i=0;itheForm.elements.length - 1;i++) {
sum +=parseInt(theForm.elements[i
Say you have 2 radio inputs one with a value of 0, the other
with a value of 1. And you have five of these..
a_1 = 0
a_2 = 1
a_3 = 0
a_4 = 0
a_5 = 1
how would you keep track of the totals?
Initially you could just do a sum of the values but what if
the user changed an option? it
9 matches
Mail list logo