Welcome to WebmasterWorld Guest from 107.22.17.186

Forum Moderators: open

Message Too Old, No Replies

javascript calculation problem

simple javascript calculation problem

     
4:38 pm on Jan 18, 2002 (gmt 0)

Junior Member

10+ Year Member

joined:Sept 12, 2001
posts:83
votes: 0


Hi

I'm very new to scripting and essentially I want to have a form that does a simple calculation based on the value entered in a text field times but the value selected in a radio. I want it to dynamically update the value in the second text field when the radio button is selected without having to click a button. I've tried the following but it doesn't work. Any advice most welcome.

<FORM>
<INPUT TYPE="TEXT" NAME="number1"> x 2<INPUT TYPE="radio" NAME="number2" value="2" onClick="this.form.answer.value = (this.form.number1.value - 0) * (this.form.number2.value - 0)">
3<INPUT TYPE="radio" NAME="number2" value="3" onClick="this.form.answer.value = (this.form.number1.value - 0) * (this.form.number3.value - 0)">
<INPUT TYPE="TEXT" NAME="answer">
</FORM>

6:57 pm on Jan 20, 2002 (gmt 0)

Senior Member

joined:June 27, 2000
posts:1548
votes: 0


Welcome Dawlish! My javascript scripting ability has remained consistant over the years: it still sucks. I'll see if I can't round up someone to help you.
5:55 am on Jan 21, 2002 (gmt 0)

Preferred Member

10+ Year Member

joined:May 9, 2001
posts:416
votes: 0


Hi dawlish,
Change the name in the second radio button to "number3" and it will work.