element access

liunx

Guest
Hi,<br />
<br />
I am having troubles understanding how those NAME and ID attributes work.<br />
<br />
For example if I have a form<br />
<br />
<form name="f1">... <table><tr><td><input name="i1"...<br />
then I can access that input by document.f1.i1<br />
<br />
if instead of a form there was a div, then it wouldn't work and I 'd have to put a name on each parent tag of my input in order to access it like this:<br />
<br />
<div name="d1">... <table name="t2"><tr name="tr"><td name="td"><input name="i1"...<br />
<br />
document.d1.t2.tr.td.i1<br />
<br />
Why is this the case? Do forms handle NAMEs in a special way?<br />
Same with IDs. If I don't want to use getElementById will I have to give an ID to each tag that encloses the tag I want to access?<br />
<br />
thanks in advance<!--content-->form element has parent child relationship with input element so you can access it like that.<br />
document.form.child...<br />
<br />
where is table is not a direct child of div element....tables are painted as individual objects in a window.<!--content-->
 
Back
Top