Hi all,
Tearing my hair out here. I'm just learning javascript on the fly here and spent half a day working in a simple calculation script where if a user clicks on a radio button and places a number in a textbox, the result appears in a "sub total" field. Here is the code on the page that works:
"input1" is the radio button with a value of 15
the "input2" is the text box that has an "onChange" event happening that will provide the answer in the "answer" field.
I got this code from this forums FAQ page
This page is located HERE
Great you say? well here is the cruncher. I have the exact same code on THIS PAGE
Look at the Creche section and the radio button for 'session 3' is supposed to multiply with the qty field next to it and provide the answer in the field on the right.
Why is it working on the first page and not this one?![[mad] [mad] [mad]](/data/assets/smilies/mad.gif)
Here is the code for the page that DOES NOT work. Any workable solution would get you a star!
Been working on this for too long!
Again, "CrSess3" is the radio button with a value of 3, "Sess3Qty" is the text field that is multiplied with the radio button and the answer is supposed to go into "Sub3"
-------------------------------------------------------------
"The most overlooked advantage of owning a computer is that if they foul up there's no law against whacking them around a bit."
Tearing my hair out here. I'm just learning javascript on the fly here and spent half a day working in a simple calculation script where if a user clicks on a radio button and places a number in a textbox, the result appears in a "sub total" field. Here is the code on the page that works:
Code:
function addthem() {
//FIRST INPUT VALUE
var add1 = document.addem.input1.value
var add1 = parseFloat(add1, 10)
add1 = (isNaN(add1))?0:add1;
//SECOND INPUT VALUE
var add2 = document.addem.input2.value
var add2 = parseFloat(add2, 10)
add2 = (isNaN(add2))?0:add2;
//ADD THEM TOGETHER
return eval(add1) * eval(add2);
}
function addition() {
document.addem.answer.value = addthem()
totalval(addem)
}
the "input2" is the text box that has an "onChange" event happening that will provide the answer in the "answer" field.
I got this code from this forums FAQ page
This page is located HERE
Great you say? well here is the cruncher. I have the exact same code on THIS PAGE
Look at the Creche section and the radio button for 'session 3' is supposed to multiply with the qty field next to it and provide the answer in the field on the right.
Why is it working on the first page and not this one?
![[mad] [mad] [mad]](/data/assets/smilies/mad.gif)
Here is the code for the page that DOES NOT work. Any workable solution would get you a star!
Been working on this for too long!
Code:
function CrecheSess3() {
//FIRST INPUT VALUE
var add1 = document.addem.CrSess3.value
var add1 = parseFloat(add1, 10)
add1 = (isNaN(add1))?0:add1;
//SECOND INPUT VALUE
var add2 = document.addem.Sess3Qty.value
var add2 = parseFloat(add2, 10)
add2 = (isNaN(add2))?0:add2;
//ADD THEM TOGETHER
return eval(add1) * eval(add2);
}
function CrecheSess3Sub(){ document.addem.Sub3.value = "$" + CrecheSes3()}
Again, "CrSess3" is the radio button with a value of 3, "Sess3Qty" is the text field that is multiplied with the radio button and the answer is supposed to go into "Sub3"
-------------------------------------------------------------
"The most overlooked advantage of owning a computer is that if they foul up there's no law against whacking them around a bit."