[Javascript] dynamically hide an element

Dong, Roland Roland_Dong at parade.com
Tue Nov 28 18:10:03 CST 2006


Hello,
 
I need to dynamically hide and unhide a selection box based on the value
selected in the first selection box.  So if a user selects "a"  in
selection box, element id2 should be visible else it should remain
hidden.  I can use
document.getElementByI("id2").style.visibility="visible" to make it
visible and document.getElementById("ed1").style.visibility="hidden"; to
make it disappear.    The problem when element id2 disappears, it still
keeps space there and it makes the form look bad.   Is there a way to
dynamically remove the space it occupies?
 
.......
<tr id="id1">
   <td>
    <select name="first" onchange="check(this)">
        <option>a</option>
        <option>b</option>
      </select>   
   <td>
</tr>
<tr id ="id2" style="visibility:hidden";>
 <td>
      <select name="second"> 
        <option>c</option>
        <option>d</option>
      </select>   
 <td>
</tr>
..............
rest of the form....
 
 
Thanks a lot,
 
Roland
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.evolt.org/pipermail/javascript/attachments/20061128/85e541cf/attachment.htm>


More information about the Javascript mailing list