This is the right way to do it:
function DH_getElementsByName(sTagName, sAttributeName) {
var cInput = document.getElementsByTagName(sTagName);
var aItems = new Array();
for(var i=0; i<cInput.length; i++) {
if (cInput[i].name == sAttributeName) {
aItems[aItems.length] = cInput[i];
}
}
return (aItems);
}
now e.g. if You have html code for two check-boxes:
<td bgcolor="#B0C4DE" width="50%">
<input type="radio" name="rboption" accesskey="S" checked
onClick="showIFrame()">
<label><b>Find by Queries</b></label>
</td>
<td bgcolor="#B0C4DE" width="50%">
<input type="radio" name="rboption" accesskey="E" onClick="showIFrame()">
<label><b>Find by Id</b></label>
</td>
then You can use JavaScript function (e.g. to show something different in
the IFRAME tag (ID:s searchbyquerydiv and manualdiv) like:
function showIFrame() {
if ((DH_getElementsByName("INPUT", "rboption"))[0].checked == true) {
document.getElementById("searchbyquerydiv").style.display = "block";
document.getElementById("manualdiv").style.display = "none";
}
if ((DH_getElementsByName("INPUT", "rboption"))[1].checked == true) {
document.getElementById("searchbyquerydiv").style.display = "none";
document.getElementById("manualdiv").style.display = "block";
}
}
Timo Ratilainen
Finland
----------------------------------------
Say you have some order lines which all are INPUT tags. They
might have the name "Itemnbr". One way to get a collection/array of them
then is to do like this:
function getElementsByName(sTagName, sAttributeName) {
var cInput =3D document.getElementsByName(sTagName);
var aItems =3D new Array();
for(var i=3D0; i<cInput.length; i++) {
if (cInput[i].name =3D=3D sAttributeName) {
aItems[aItems.length] =3D cInput[i];
}
}
return (aItems);
}
var myItemCollection =3D getElementsByName('input', 'Itemnbr');