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
merge events from one calendar to specific users calendar
Chrome: click()
Passing value from one page textbox to another page textboxes
How to copy line chart color and apply on on the chart title (Excel 2007/VBA)
Mirrored SBS for backup
Populate hidden fields with JavaScript problem
C# regular expression question (replace)
need to display information with a scroll bar.
SQL 2008 date data type ODBC link to Access 2007 changes to text data type
What was the name of pharaoh's daughter that took off Moshes from water?