|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
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
|
|||
|
|||
|
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! |
|
#2
|
||||
|
||||
|
Code:
document.PAY.elements['amount'+i].value=...; |
![]() |
| Viewing: Dev Articles Community Forums > Programming > JavaScript Development > Use a variable form field name |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|