JavaScript Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingJavaScript Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
Ajax Application Generator Generate database and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
  #1  
Old May 31st, 2005, 05:00 PM
rovi rovi is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2005
Posts: 1 rovi User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 m 46 sec
Reputation Power: 0
Use a variable form field name

Hi,
I have this javascript code that passes a value to a form field, but the form field name is variable and depends on the variable i.
if (i==2){
document.PAYamount_2.value=document.FINAL.SELSHIPP ING.value;
}else if (i==3){
document.PAY.amount_3.value=document.FINAL.SELSHIP PING.value;
}else if (i==4){
document.PAY.amount_4.value=document.FINAL.SELSHIP PING.value;

How could I construct the form field such that I dont have to write the if else statements and just use variable (like:
document.PAY.amount_[i].value=document.FINAL.SELSHIPPING.value;

Thanks!

Reply With Quote
  #2  
Old May 31st, 2005, 05:16 PM
ChiefWigs1982's Avatar
ChiefWigs1982 ChiefWigs1982 is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2005
Location: I have emerged from the place of spells and fairies
Posts: 97 ChiefWigs1982 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 Days 17 h 35 m 12 sec
Reputation Power: 4
Code:
document.PAY.elements['amount'+i].value=...;

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingJavaScript Development > Use a variable form field name


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway