Jump to content

little javascript error


villermen
 Share

Recommended Posts

Couldn't find anything about this on the internet, so I'll just ask it here.My JavaScript code will not work because I can't use getElementsByName twice.I tried to fix this by using names, but I can't think of a solution now.

					   <table>						<tr class="dung_row" name="row8">					<td class="dung_column" name="column1"> </td>					<td class="dung_column" name="column2"> </td>					<td class="dung_column" name="column3"> </td>					<td class="dung_column" name="column4"> </td>					<td class="dung_column" name="column5"> </td>					<td class="dung_column" name="column6"> </td>					<td class="dung_column" name="column7"> </td>					<td class="dung_column" name="column8"> </td>			</tr>		</table>			<script type="text/javascript">			document.getElementsByName("row8")[0].column1.innerHTML="BASE";		</script>

Please help me fix the line starting with "document.getElem..."shouldn't document.row8.column1.innerHTML work?Gr.Villermen

Edited by villermen
Link to comment
Share on other sites

My JavaScript code will not work because I can't use getElementsByName twice.
Why can't you use it twice? Has your local government passed a law saying that you're only allowed to use it once?Look into the DOM methods, there are several ways to access a node's children other than by referring to them by name. You can access the first child, the next, etc.http://www.howtocreate.co.uk/tutorials/javascript/dombasics
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...