W3C DOM tests - getElementsByName()

There are four elements that have name="test". This paragraph is the first. This image is the next:

The checkbox above is the third; and this <ppk> tag the fourth.

Finally, this div has id="test" (and not name). It should be ignored.

This page contains test cases for getElementsByName().

Test scripts

getElementsByName()

Correct answers: 4 and 'P, IMG, INPUT, PPK' (in any order)

var x = document.getElementsByName('test');
alert(x.length);
var writestring = '';
for (var i=0,test;test=x[i];i++)
	writestring += x[i].nodeName + ' ';
alert(writestring);