Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I prevent a row in a table from being displayed in JavaScript??

Status
Not open for further replies.

slydog92

MIS
Jul 7, 1999
2
US
I'm in the process of converting some vBScript to JavaScript and having some problems. I have a table with two rows with ids trBusiness and trHome. I also have two input fiels of type radio. Depending of which of these inputs is chosen I want to prevent trBusiness or trHome from being displayed. I did this in VBScript by doing the following:<br>
<br>
// if Businss is chosen <br>
sub clkBus()<br>
document.all.trBusiness.style.display = ""<br>
document.all.trHome.style.display = "none"<br>
end sub<br>
<br>
// if Home is chosen<br>
sub clkRes()<br>
document.all.trBusiness.style.display = "none"<br>
document.all.trHome.style.display = ""<br>
end sub<br>
<br>
I thought that I could use the same syntax (document.all.trBusiness.style.display = "none") in JavaScript accomplish the same task. But when I view it in the browser (I've tried both IE 4 and Navigator 4.6) it "bombs" at this line. How would I go about preventing a row from being displayed in javascript? Is my syntax wrong?<br>

 
I apologize. It was working in IE the whole time but it doesn't want to work for me in Navigator. So the problem seems to be in the browser. Could anyone explain why it wouldn't work in Navigator?
 
Hmmm; not sure on any explanation; but one thing you might try in Netscape to hide a &lt;tr&gt; would be to insert a line of JS RIGHT BEFORE the &lt;tr&gt; tag that inserts a "&lt;!--" before the &lt;tr&gt; tag when one of the rdo buttons is clicked; & an (almost) identical scriptlet AFTER the &lt;/tr&gt; tag.......this SHOULD "comment out" the row...I'm jsut not sure if there would then be any way to bring it back (aside from using document.writeln to totaly re-write it at the bottom of the page.<br>
<br>
-Robherc<br>
robherc@netzero.net
 
I've experienced this problem before. Do you have your entire script inside the table? Including the Variable definitions? Make sure that all of your script is inside the same table.
 
None of those will work in NS4, as NS4 is the worst supposed DHTML browser ever created. They thought it would be &quot;cool&quot; if you could only show/hide layers. So you may have to place each table row in a different layer, and hide the layers:

document.layers.layername.visibility='hide'
document.layers.layername.visibility='show' jared@eae.net -
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top