FRIHOSTFORUMSFAQTOSBLOGSDIRECTORY
You are invited to Log in or Register a Frihost Account!

[solved]show / hide table row. Something is wrong

 


devroom
Hi

Solved. Edited the code below to the code which is right. Thx to shamil.
The problem was also caused by the css code. The lines have moved to the tr row.

javascript code:
Code:
<script type="text/javascript">
<!--
function ShowHide(id)
{
   var tr = document.getElementById(id);
   if (tr == null) { return; }
   var trExpand = tr.style.display == '';
   tr.style.display = (trExpand ? 'none' : '');
}
//-->
</script>


Html code:
Code:
table class="admintable" width="100%">
  <tr>
   <td class="key">Mail on a message :</td>
   <td>
   <input type="radio" name="mailonnew" id="mailonnew0" value="0" checked="checked" class="inputbox" onclick="javascript:ShowHide('sendmessage');" />
   <label for="mailonnew0">No</label>
   <input type="radio" name="mailonnew" id="mailonnew1" value="1" class="inputbox" onfocus="javascript:ShowHide('sendmessage');" />
   <label for="mailonnew1">Yes</label>
   </td>
  </tr>
  <tr id="sendmessage" style="display:none">
   <td class="key">Send the message :</td>
   <td>
   <input type="radio" name="sendmessage" id="sendmessage0" value="0" checked="checked" class="inputbox" />
   <label for="sendmessage0">No</label>
   <input type="radio" name="sendmessage" id="sendmessage1" value="1" class="inputbox" />
   <label for="sendmessage1">Yes</label>
</td>
 </tr>


I hope some of you do know why the show / hide function doesnt work. If you need more info, please say.

Grtz and thx in advance Very Happy


Last edited by devroom on Sat Oct 28, 2006 10:25 am; edited 2 times in total
shamil
You need to enclose sendmessage in quotes unless u send object to function. And change onselect to onclick. I don't think onselect event exists.
Html
Code:
<table class="admintable" width="100%">
  <tr>
   <td class="key">Mail on a message :</td>
   <td>
   <input type="radio" name="mailonnew" id="mailonnew0" value="0" checked="checked" class="inputbox" onclick="javascript:showhide('sendmessage');" />
   <label for="mailonnew0">No</label>
   <input type="radio" name="mailonnew" id="mailonnew1" value="1" class="inputbox" onclick="javascript:showhide('sendmessage');" />
   <label for="mailonnew1">Yes</label>
</td>
  </tr>
  <tr id="sendmessage">
   <td class="key">Send the message :</td>
   <td>
   <input type="radio" name="sendmessage" id="sendmessage0" value="0" checked="checked" class="inputbox" />
   <label for="sendmessage0">No</label>
   <input type="radio" name="sendmessage" id="sendmessage1" value="1" class="inputbox" />
   <label for="sendmessage1">Yes</label>
</td>
 </tr>
shamil
It is not right thing to edit post to solved version when problem is solved just add another post if you want to add something. You have made second post meaningless and needless for users or guests to view it.
devroom
shamil wrote:

It is not right thing to edit post to solved version when problem is solved just add another post if you want to add something. You have made second post meaningless and needless for users or guests to view it.


I believe not. If some users want to hide or show a tr by javascript, he will find this post, which contains the right info.
Reply to topic    Frihost Forum Index -> Scripting -> Html, CSS and Javascript

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2007 Frihost, forums powered by phpBB.