Friday, May 17, 2024
 Popular · Latest · Hot · Upcoming
149
rated 0 times [  150] [ 1]  / answers: 1 / hits: 114326  / 14 Years ago, sat, june 5, 2010, 12:00:00

This simple JS can't set the value of para. I guess getElementByName doesn't work. But why?



<script>
function fn()
{
document.getElementById(para).setAttribute(name,hi);
document.getElementByName(hi).setAttribute(value,my value is high);
}
</script>


HTML:



<input type=button onClick=fn() value=click me>
<input id=para type=text />

More From » javascript

 Answers
47

It's getElementsByName . Note the plural. It returns an array-like NodeList of elements with that name attribute.


[#96576] Wednesday, June 2, 2010, 14 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
collinisaaka

Total Points: 194
Total Questions: 105
Total Answers: 104

Location: Tonga
Member since Tue, Nov 30, 2021
3 Years ago
;