Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > JavaScript Assistance

JavaScript Assistance
Thread Tools
pumpkinapo
Junior Member
Join Date: Aug 2000
Location: Califon, NJ
Status: Offline
Reply With Quote
Jul 30, 2003, 04:04 PM
 
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
     
clam2000
Dedicated MacNNer
Join Date: Aug 2002
Status: Offline
Reply With Quote
Jul 31, 2003, 12:39 AM
 
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
     
sjdownes
Fresh-Faced Recruit
Join Date: Sep 2000
Location: Atlanta, GA
Status: Offline
Reply With Quote
Jul 31, 2003, 02:32 PM
 
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?
     
pumpkinapo  (op)
Junior Member
Join Date: Aug 2000
Location: Califon, NJ
Status: Offline
Reply With Quote
Aug 4, 2003, 09:55 AM
 
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
     
pumpkinapo  (op)
Junior Member
Join Date: Aug 2000
Location: Califon, NJ
Status: Offline
Reply With Quote
Aug 13, 2003, 11:17 AM
 
I'm all good. I found my solution here:
http://www.pxl8.com/cloneNode_name_id.html
Peter Leing
17" 1.67GHz PowerBook
450MHz G4 Cube
     
   
Thread Tools
 
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Top
Privacy Policy
All times are GMT -4. The time now is 07:52 AM.
All contents of these forums © 1995-2017 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2017, Jelsoft Enterprises Ltd.,