dannycec
10-23-2003, 10:38 PM
I am setting up a page with frames, where the bottom half of the page is a form with up to 100 rows, and 20 columns. The table is dynamically created with PHP.
My problem is with the top frame, I need to update that with a number, relevant to what has been entered in the column below it, in the bottom frame. The numbers are 1 to 8 only.
I have managed to do this on a small table, with 2 columns, and 10 rows, but the Javascript needed for this is 1000 rows long. To do a page like what i need will require thousands upon thousands of rows of code...It needs to be much smaller.
the code currently looks like this:
if (form2.b1_0.value == '1')
{
tempb1=tempb1+1;
}
It repeats this for each form field, something like this: b1_0..b1_1..b1_2, ect. Also, the == '1' part needs to change, but i am able to do this in PHP, by looping it.
I have tried some code, which loops through the form, using a variable if statement, but it dosen't work. Hopefully someone can help me with it.
The code is as follows:
var total_rows = 2;
var tempb1 = 0;
function changeb1() {
var count = 0;
while (count <= total_rows) {
if ('form2.b1_'+count+'.value' == '1')
{
tempb1=tempb1+1;
}
count = count + 1;
}
}
The function is involked on a onchange event, within the form fields.
My problem is with the top frame, I need to update that with a number, relevant to what has been entered in the column below it, in the bottom frame. The numbers are 1 to 8 only.
I have managed to do this on a small table, with 2 columns, and 10 rows, but the Javascript needed for this is 1000 rows long. To do a page like what i need will require thousands upon thousands of rows of code...It needs to be much smaller.
the code currently looks like this:
if (form2.b1_0.value == '1')
{
tempb1=tempb1+1;
}
It repeats this for each form field, something like this: b1_0..b1_1..b1_2, ect. Also, the == '1' part needs to change, but i am able to do this in PHP, by looping it.
I have tried some code, which loops through the form, using a variable if statement, but it dosen't work. Hopefully someone can help me with it.
The code is as follows:
var total_rows = 2;
var tempb1 = 0;
function changeb1() {
var count = 0;
while (count <= total_rows) {
if ('form2.b1_'+count+'.value' == '1')
{
tempb1=tempb1+1;
}
count = count + 1;
}
}
The function is involked on a onchange event, within the form fields.