View Full Version : getting elements by part of their name
sliad
05-26-2004, 10:54 AM
I have some input elements. I want to get an element by using a method like "document.getElementsByName" but I want to give this function a part of the name string of the element.
for example: I have the element by the name: "N43:flag" ,
and I want to find it using the string: "flag" .
bocmaxima81
06-11-2004, 03:24 PM
I have some input elements. I want to get an element by using a method like "document.getElementsByName" but I want to give this function a part of the name string of the element.
for example: I have the element by the name: "N43:flag" ,
and I want to find it using the string: "flag" .
eval('document.getElementsByName(\"'+yourvariable+'flag\").whatever')
Remember that document.getAnything only works with DOM browsers. So your script won't work in IE 5.x and NS 4.x.
-colin
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.