pinkotoad
07-22-2002, 09:05 PM
I'm trying to write a simple script (I hope its simple):[list=1]
If the value of the select box is 1001, then I want to assign the variable TEST1 a value of 50
If the value is not 1001 then I would like TEST1 to equal 0.
The same goes for TEST2
[/list=1]
The problem I am having TEST1 is ALWAYS 50 and TEST2 is ALWAYS 70, so I have a sneaking suspicion that I am misusing else, or just leaving something out.
function ComputeTotal(form)
{
if (document.form.test.value = 1001)
TEST1 = 50
else
TEST1 = 0
if (document.form.test.value = 1002)
TEST2 = 70
else
TEST2 = 0
subtotal = (TEST2 + TEST1)
document.form.total.value = subtotal
}
Eventually there will be more than 2 options per select box and I need the value to be an inventory number instead of just the mere price.
Also while I'm here, I have another question: Would it be possible to have a non numerical value for the options in select box "test" and if so, how would I define them? (I tried making the values "testa" and "testb" but it kept coming back saying that "testa is undefined")
Forgive me for my "noobness".
If the value of the select box is 1001, then I want to assign the variable TEST1 a value of 50
If the value is not 1001 then I would like TEST1 to equal 0.
The same goes for TEST2
[/list=1]
The problem I am having TEST1 is ALWAYS 50 and TEST2 is ALWAYS 70, so I have a sneaking suspicion that I am misusing else, or just leaving something out.
function ComputeTotal(form)
{
if (document.form.test.value = 1001)
TEST1 = 50
else
TEST1 = 0
if (document.form.test.value = 1002)
TEST2 = 70
else
TEST2 = 0
subtotal = (TEST2 + TEST1)
document.form.total.value = subtotal
}
Eventually there will be more than 2 options per select box and I need the value to be an inventory number instead of just the mere price.
Also while I'm here, I have another question: Would it be possible to have a non numerical value for the options in select box "test" and if so, how would I define them? (I tried making the values "testa" and "testb" but it kept coming back saying that "testa is undefined")
Forgive me for my "noobness".