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
Exchange 2007 BCC field Limit?
query result seems to change number to text
Adding a 2nd domain to Exchange 2007 on SBS 2008 box
Windows 2000 server and USB 2.0 Iomega External HDD
Moving iTunes Library to a New PC
How to get the number of the date of every Wednesday from now until year end
Adding items to the List through check boxes via Grid view
Scale one data series in Excel bar graph
order by (-) number
Configure Mac to recognize Windows workgroup