pjfarley3 Posted April 5, 2006 Share Posted April 5, 2006 I saw the example of how to change the contents of a table cell (pure text data change). I need to *sometimes* insert an <anchor> as the data in a table cell, and sometimes leave it as " ".The function to decide which rows get an <anchor> and which rows get " " would be made in the "onload" event for the document, based on the content of the first column of the row (when first cell is " ", last cell of row should also be " ", otherwise it needs to be an <anchor>).DOM solution preferred, IE-only is OK if that's all there is.TIA for any help you can provide.Peter Link to comment Share on other sites More sharing options...
scott100 Posted April 5, 2006 Share Posted April 5, 2006 If you find the inner.HTML of the first row you can check it's value in a control struture. Depending on this value you can write a value to the second row, either a space or a link.This should do what you need. <head><script>function check(){ for(i=1;i<=4;i++){ if(document.getElementById(i+'a').innerHTML==" ") { document.getElementById(i+'b').innerHTML=" "; } else { document.getElementById(i+'b').innerHTML="<a href='http://www.google.com'>Google</a>"; }}}</script></head><body onload="check()"><table border="1"><tr><td id="1a"> </td><td id="1b"></td></tr><tr><td id="2a">I have content</td><td id="2b"></td></tr><tr><td id="3a"> </td><td id="3b"></td></tr><tr><td id="4a">I also have content</td><td id="4b"></td></tr></table></body> Link to comment Share on other sites More sharing options...
pjfarley3 Posted April 5, 2006 Author Share Posted April 5, 2006 If you find the inner.HTML of the first row you can check it's value in a control struture. Depending on this value you can write a value to the second row, either a space or a link.This should do what you need.<{POST_SNAPBACK}> Thank you Scott. That does work.Peter Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now