TheCommunicator
asked on
GetElementbyName in Javascript
Hi Guys,
I have following small code snipped in Javascript
Here the var "Something " definately has tow values and when I do obj.value for each one then it comes back as undefined. BUt when I do something[0].value then it returns the real value. I am not sure what is wrong with this code?
I have following small code snipped in Javascript
var something = document.getElementsByName('key');
for(obj in something) {
alert(obj.value)
Here the var "Something " definately has tow values and when I do obj.value for each one then it comes back as undefined. BUt when I do something[0].value then it returns the real value. I am not sure what is wrong with this code?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Yes but can't is read through that array using for(obj in something)?
look like not
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
sorry, I meant to add that in your original example, you would want to write
for(obj in something) {
alert(something[obj].value)
}
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you so much guys that was useful information.
ASKER