Howard,

Could you possibly take a look at http://www.dinnys.com/create.html. This is a first shot at doing what you suggested, I think!
Please excuse the fact that things don't line up, but...


when I place a number in one of the four boxes in the second col, I get a script error that says that one of my ID'd boxes is not an object. It certainly is there on the page, but I must be referencing it wrong. Could you tell me what I did wrong?

Thanks,
steve





On Mar 8, 2005, at 5:47 PM, Howard Cheng wrote:

You'll want to use IDs to uniquely identify each your text boxes. For example, even though the name of the form object is singles[], give each one an ID of 'single1', 'single2', etc. Then you can loop through them like such:

var i = 1;
var total = 0;
while (document.getElementById("single" + i) != null)
{
    total += parseInt(document.getElementById("single" + i).value);
    i += 1;
}

Repeat as necessary. Or to be more sophisticated, make an array of your form object names so that you can loop through that and in each iteration run this while loop.

steve miller wrote:
Hi all.
Could use some help with javascript.
I am loading up a page with a variable number of columns depending on selections made on a previous screen. Each column contains identical textboxes which have identical names so php will deal with them as arrays (like singles[], parents[], children[], etc in this case) when submitted. When the page loads, I need to multiply a value from another textbox (that is not part of an array) by each of these boxes in a column, add the totals up, and enter the final value into yet another box. My problem is that I don't know how to reference the array boxes in javascript since they all have the same name. I need to do it in js so changes can be made and calcs done in the browser.
In other words, how do I tell javascript to use the boxes in col 1 for the first calc, then move on to the boxes in col 2 for the next calc...
There are also a gazillion other textboxes on the same page which are not used in the calc, so I don't think I can refernce them using form element numbers.
How do i do what I want to do?
steve

-- :::::::::::::::::::::::::::::: Howard Cheng http://www.howcheng.com/ Wise-cracking quote goes here.

____ • The WDVL Discussion List from WDVL.COM • ____
To Join wdvltalk, Send An Email To: mailto:[EMAIL PROTECTED] or
use the web interface http://e-newsletters.internet.com/discussionlists.html/
Send Your Posts To: [email protected]
To change subscription settings, add a password or view the web interface:
http://intm-dl.sparklist.com/read/?forum=wdvltalk


________________  http://www.wdvl.com  _______________________

You are currently subscribed to wdvltalk as: [EMAIL PROTECTED]
To unsubscribe send a blank email to [EMAIL PROTECTED]
To unsubscribe via postal mail, please contact us at:
Jupitermedia Corp.
Attn: Discussion List Management
475 Park Avenue South
New York, NY 10016


Please include the email address which you have been contacted with.



____ • The WDVL Discussion List from WDVL.COM • ____
To Join wdvltalk, Send An Email To: mailto:[EMAIL PROTECTED] or
use the web interface http://e-newsletters.internet.com/discussionlists.html/
      Send Your Posts To: [email protected]
To change subscription settings, add a password or view the web interface:
http://intm-dl.sparklist.com/read/?forum=wdvltalk

________________  http://www.wdvl.com  _______________________

You are currently subscribed to wdvltalk as: unknown lmsubst tag argument: ''
To unsubscribe send a blank email to [EMAIL PROTECTED]
To unsubscribe via postal mail, please contact us at:
Jupitermedia Corp.
Attn: Discussion List Management
475 Park Avenue South
New York, NY 10016

Please include the email address which you have been contacted with.

Reply via email to