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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Extracting the 3 most right character of an Element ID

Status
Not open for further replies.

Mayoor

Programmer
Jan 16, 2004
198
GB
I would like to loop through the form elements and test to see where the 3rd character of the ID name is a "3".

if TheElem.id.CharAt(2) == 3

Can I simply just do this?
 
Not quite... although you're almost there. charAt has a lowercase "C" at the beginning... remember that JS is case-sensitive.

Also, you're missing brackets around your "if" test. Try this:

Code:
if (TheElem[i].id.charAt(2) == '3') {
   // do something here
}

This, of course, assumes that "TheElem" is a valid form element.

Hope this helps,
Dan


[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Don't see why that wouldn't work.

Tracy Dryden

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard. [dragon]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top