javascript functions

Status
This thread has been Locked and is not open to further replies. The original thread starter may use the Report button to request it be reopened but anyone else with a similar issue should start a New Thread. Watch our Welcome Guide to learn how to use this site.

yusuf21

Thread Starter
Joined
Sep 20, 1999
Messages
46
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)



Code:
<tr>
Code:
<input type=text name="q1">
Code:
<input type=text name="q1_value">
Code:
<input type=text name="q1_total">
Code:
</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>...
[/CODE]

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
 
Status
This thread has been Locked and is not open to further replies. The original thread starter may use the Report button to request it be reopened but anyone else with a similar issue should start a New Thread. Watch our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 807,865 other people just like you!

Latest posts

Staff online

Members online

Top