starsky51
MIS
- Mar 11, 2002
- 91
Hi All,
I need to find a way to reference the childNodes of a form by their id/name.
I have pasted an example of what i am trying to do. I can reference the node by number (eg. document.f1.childNodes[1]) but not by name. document.getElementById("d2") will not work because there is more than one element with the name "d2".
Does anyone have any ideas?
Dave.
I need to find a way to reference the childNodes of a form by their id/name.
I have pasted an example of what i am trying to do. I can reference the node by number (eg. document.f1.childNodes[1]) but not by name. document.getElementById("d2") will not work because there is more than one element with the name "d2".
Does anyone have any ideas?
Dave.
Code:
<html>
<script language="javascript">
function hidef1d2() {
document.f1.childNodes["d2"].style.display = "none";
}
</script>
<body>
<form id="f1" name="f1">
<div id="d1" name="d1">
<input id="i1" name="i1" type="text"/><br/>
<input id="i2" name="i2" type="text"/><br/>
</div>
<div id="d2" name="d2">
<input id="i3" name="i3" type="text"/><br/>
<input id="i4" name="i4" type="text"/><br/>
</div>
</form>
<form id="f2" name="f2">
<div id="d1" name="d1">
<input id="i1" name="i1" type="text"/><br/>
<input id="i2" name="i2" type="text"/><br/>
</div>
<div id="d2" name="d2">
<input id="i3" name="i3" type="text"/><br/>
<input id="i4" name="i4" type="text"/><br/>
</div>
</form>
<input type="button" value="hidef1d2" onclick="hidef1d2();"/>
</body>
</html>