|
|
JavaScript Assistance
|
|
|
|
Junior Member
Join Date: Aug 2000
Location: Califon, NJ
Status:
Offline
|
|
I'm working on a web based project time tracking system and have run into an issue I can't solve. I need to sum up the time textfields. The issue is the textfields all have the same name. Is there a way I can iterate through the textfields and add their values?
(
Last edited by pumpkinapo; Aug 13, 2003 at 11:16 AM.
)
|
Peter Leing
17" 1.67GHz PowerBook
450MHz G4 Cube
|
|
|
|
|
|
|
|
Dedicated MacNNer
Join Date: Aug 2002
Status:
Offline
|
|
yes
when you think about it this is the same as trying to deal with a select menu that has more then one item selected.
if each of them is 'time[]' it becomes an array when you are dealing with it. (so you can call them as time[0]+time[1]+...)
This worked for me using PHP as the back-end. In javascript you can take a shortcut and refer by element#:
Code:
document.forms[0].elements[0];
I would be happy to show you how to import it into php if you need to know that.
--will
|
|
|
|
|
|
|
|
|
Fresh-Faced Recruit
Join Date: Sep 2000
Location: Atlanta, GA
Status:
Offline
|
|
Using the elements array would work, but that's a fragile way to do things, subject to breaking every time you add a new form element.
My question would be why on earth are all the time text fields named the same thing?
|
|
|
|
|
|
|
|
|
Junior Member
Join Date: Aug 2000
Location: Califon, NJ
Status:
Offline
|
|
I'm using the W3C's DOM cloneNode() to duplicate the entry row. This created an identical row with all the field objects but with the same name.
http://www.apoforum.com/time/time.html
(I'm developing this app on a windows computer and don't know what mac browsers it'll work in since it doesn't seem to work in firebird's 8/3 build only IE 6.)
|
Peter Leing
17" 1.67GHz PowerBook
450MHz G4 Cube
|
|
|
|
|
|
|
|
Junior Member
Join Date: Aug 2000
Location: Califon, NJ
Status:
Offline
|
|
|
Peter Leing
17" 1.67GHz PowerBook
450MHz G4 Cube
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Forum Rules
|
|
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
|
|
|
|
|
|