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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Show / Hide two HTML tables

Status
Not open for further replies.

vilrbn

Programmer
Oct 29, 2002
105
0
0
FR
Hello,

I'm using a radio button. Depending on the value, I need to show Tables1 /hide Table2 or vice-versa.
The problem is that I only see empty cells. Do I have to also show / hide each row of the tables ?

Here is an extract of my code:

<script type=&quot;text/javascript&quot;>
function showHideTable(TableShow,TableHide)
{
if (document.getElementById(TableShow).style.display== 'none')
{
document.getElementById(TableShow).style.display='block';
document.getElementById(TableHide).style.display='none';
}
else
{
document.getElementById(TableShow).style.display='none';
document.getElementById(TableHide).style.display='block';
}
}
</script>


<td><input id=&quot;rblChoice1&quot; onclick=&quot;showHideTable('Table1','Table2');&quot; type=&quot;radio&quot; runat=&quot;server&quot; onserverclick=&quot;rblChoice_SelectedIndexChanged&quot;>
Choice1<br>
<input id=&quot;rblChoice2&quot; onclick=&quot;showHideTable('Table2','Table1');&quot; type=&quot;radio&quot; runat=&quot;server&quot; onserverclick=&quot;rblChoice_SelectedIndexChanged&quot;>
Choice2</td>

<table id=&quot;Table1&quot; cellSpacing=&quot;2&quot; cellPadding=&quot;2&quot; border=&quot;1&quot; runat=&quot;server&quot;>
<tr>
<td vAlign=&quot;top&quot;><asp:label id=&quot;lbl1&quot; runat=&quot;server&quot; Visible=&quot;False&quot;>bla bla</asp:label></td>
</tr>
</table>

<table id=&quot;Table2&quot; cellSpacing=&quot;2&quot; cellPadding=&quot;2&quot; border=&quot;1&quot; runat=&quot;server&quot;>
<tr>
<td vAlign=&quot;top&quot;><asp:label id=&quot;lbl2&quot; runat=&quot;server&quot; Visible=&quot;False&quot;>bla bla</asp:label></td>
</tr>
</table>


 
Hi,
You are making the lables in the <td> tag invisible. Put visible=&quot;true&quot; the you are fine

Thanks
Srinivas
 
Yes, you're right.
But I want them not to be visible at load. is it possible to use javascript on not visible controls ?
After a click on the radio button, they are set to visible = true within the VB code-behind.
I encountered another problem with the radio buttons.

On HTML side, I have two events: onclick, onserverclick.
On VB side, it only shows me a onserverchange event !!
As a result, the event occurs once the radio button looses focus and not after the click...

Protected WithEvents rblChoice1 As System.Web.UI.HtmlControls.HtmlInputRadioButton

I'm lost !
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top