
October 26th, 2001, 09:23 AM
|
|
Junior Member
|
|
Join Date: Dec 2000
Location: toronto, ontario, canada
Posts: 10
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
javascript functions
I have a form which is organized with a table, each row of the table has several form elements (at least 3 text fields each)
<form>
<tr>
<input type=text name="q1">
<input type=text name="q1_value">
<input type=text name="q1_total">
</tr>
<tr>
<input type=text name="q2">
<input type=text name="q2_value">
<select option ... name="q2_dazy">
<input type=text name="q2_total">
</tr>
...
<tr>
<input type=text name="q30">
<input type=text name="q30_value">
<select size=1 ... name="q30_dazy">
<select size=1 ... name="q30_lazy">
<input type=text name="q30_total">
</tr>...
<form>
Now I'm writing a javascript function, that'll fill in *_total based on *_value and a constant. i.e. q3_total = q3_value * 50;
My problem is that my way is really long, I have a lot of if statements to do it. Is there a better way?
my way:
function(name)
if (name == q1)
q1_total = q1_value * 50;
...
if (name == q30)
q30_total = q30_value * 50;
9
|