Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I count dynamic elements by their ID 1

Status
Not open for further replies.

LyndonOHRC

Programmer
Sep 8, 2005
603
US
Hi, I'm writing a form to scan an unknown number of barcode labels. The technique I’m trying is to use is to store the data in hidden input elements. To give them unique id’s I need to count how many have an id beginning with the string “CurrentValue“ so I can concatenate the count to the string I’m using for my id .

What I have so far:
Code:
[COLOR=red]//NextElement=count how many have an id beginning with the string “CurrentValue“[/color]

var NewHiddeninput=document.createElement("input");
NewHiddeninput.id='CurrentValue'+NextElement;
NewHiddeninput.type='Hidden';
NewHiddeninput.value=document.Scan.label1.value;
document.Scan.appendChild(NewHiddeninput);
Thanks

Lyndon

---People Remember about 10% of what you say ---They never forget how you made them feel. Covey
 
If you're building up the form youself, why not initialise a global variable to "1" and then increment it after each input you create, and use that to build the unique IDs?

Hope this helps,
Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Dan, I was having trouble seeing the forrest for the trees. LOL

Thanks Again!
Lyndon

Lyndon

---People Remember about 10% of what you say ---They never forget how you made them feel. Covey
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top