<form method="POST" name="newform" action="--WEBBOT-SELF--">
<tr onclick="alert('newform.test.value')"><td><input type="checkbox" name="test" value="345"></td></tr>
</form>
<tr onclick="alert('newform.test.value')"><td><input type="checkbox" name="test" value="345"></td></tr>
</form>
不过这样不太精确。可惜我这边ie5不知道为什么不支持firstchild
假如:
<form name="testform">
<table>
<tr><td><input type="checkbox" name="test" value="1"></td><td>1</td></tr>
<tr><td><input type="checkbox" name="test" value="2"></td><td>2</td></tr>
<tr><td><input type="checkbox" name="test" value="3"></td><td>3</td></tr>
<tr><td><input type="checkbox" name="test" value="4"></td><td>4</td></tr>
</table>
当单击每一行时想得到该行的checkbox的值。
<table>
<tr><td><input type="checkbox" name="test" value="1"></td><td onClick="call(this)">1</td></tr>
<tr><td><input type="checkbox" name="test" value="2"></td><td onClick="call(this)">2</td></tr>
<tr><td><input type="checkbox" name="test" value="3"></td><td onClick="call(this)">3</td></tr>
<tr><td><input type="checkbox" name="test" value="4"></td><td onClick="call(this)">4</td></tr>
</table>
<SCRIPT>
function call(td) {
alert(td.previousSibling.childNodes[0].value);
}
</SCRIPT>
然后,var sStr=td01.onclick;