Microsoft
Software
Hardware
Network
Question : javascript
Hello i have 5 textbox with the same name , the only thing that change is the number at the end of the name
let say:
document.Invoice.txtName1.
value
document.Invoice.txtName2.
value
document.Invoice.txtName3.
value
how can i just change the number for a variable:
something like
var x = 1;
document.Invoice.txtName(x
).value
document.Invoice.txtName(x
).value
document.Invoice.txtName(x
).value
so i can run a for 3 times and don,t have to write all the code for each field.
Answer : javascript
use the id attribute for this
<input type="text" id='txt1'>
<input type="text" id='txt2'>
<input type="text" id='txt3'>
for ( var counter = 1; counter <= 3; counter++ )
{
alert(document.getElementB
yId("txt" + counter ).value);
}
Random Solutions
Excel Formula to search 2 lists to produce a 3rd list
How to make hp nx7300 start?
Saving 3ds Max 2009 files taking ages !!
Email on completed Scheduled Task
Vmware and VMFS question - please advise!
Upgrading laptop hard drive
goto aspx page based on id value
Bootable Settings error
How to get the database record count in MS SQL Server 2005?
Terminal Server Error - RPC server is unavaliable