show/hide an html table row 
Author Message
 show/hide an html table row

Is there a way to hide/show a row in a table when a user selects an item
from an option list?  For instance, I know how to hide a textbox using the
style.display property of the textbox, but that does not hide the text that
I have to the left of the textbox.  Here's what I've got:

<form method="post" action="page2.asp" id="form1" name="form1">
<table>
<tr><td>Search:</td><td>
<select id="select1" name="select1">
<option Value="0">Select data</option>
<option Value="0">---------------------</option>
<option Value="1">Data 1</option>
<option Value="2">Data 2</option>
<option Value="3">Data 3</option>
</select></td></tr>
<tr><td>First Name:</td><td><INPUT type="text" id=text1
name="FName"></td></tr>
<tr><td>Last Name:</td><td><INPUT type="text" id=text2
name="LName"></td></tr>
<tr><td>SSN:</td><td><INPUT type="text" id=text2 name="SSN"></td></tr>
</form>

<script language=VBScript>
sub select1_onchange()
    if document.form1.select1.value = 1 then
        document.form1.ssn.style.display = "none"
    end if
end sub
</script>

This will not remove the label "SSN:" from my form.  Is there a way to do
this?  Thanks

mike



Mon, 26 Nov 2001 03:00:00 GMT  
 show/hide an html table row
Give the SSB row an ID then hide the row.  For example:

<tr id=SSN><td>SSN:</td><td><INPUT type="text" id=text2
name="SSN"></td></tr>
</form>

<script language=vbscript>
sub select1_onchange()
    if document.form1.select1.value = 1 then
        document.all("SSN").style.display = "none"
    end if
end sub
</script>



Mon, 26 Nov 2001 03:00:00 GMT  
 show/hide an html table row
i tried that, but i get the error "Object doesn't support this property or
method: document.all(...).style".  i have also tried some variations of this
with no luck.  anyone have any ideas?
Quote:

>Give the SSB row an ID then hide the row.  For example:

><tr id=SSN><td>SSN:</td><td><INPUT type="text" id=text2
>name="SSN"></td></tr>
></form>

><script language=vbscript>
>sub select1_onchange()
>    if document.form1.select1.value = 1 then
>        document.all("SSN").style.display = "none"
>    end if
>end sub
></script>



Mon, 26 Nov 2001 03:00:00 GMT  
 show/hide an html table row
Try giving the <tr> an id that isn't the same as the name attribute on the
<input> contained in the row.

--
Michael Harris


| i tried that, but i get the error "Object doesn't support this property or
| method: document.all(...).style".  i have also tried some variations of
this
| with no luck.  anyone have any ideas?
|
| >Give the SSB row an ID then hide the row.  For example:
| >
| ><tr id=SSN><td>SSN:</td><td><INPUT type="text" id=text2
| >name="SSN"></td></tr>
| ></form>
| >
| >
| ><script language=vbscript>
| >sub select1_onchange()
| >    if document.form1.select1.value = 1 then
| >        document.all("SSN").style.display = "none"
| >    end if
| >end sub
| ></script>
| >
| >
| >
| >
| >
|
|



Mon, 26 Nov 2001 03:00:00 GMT  
 show/hide an html table row
Try putting a div around it....you'll need to put it around the whole <tr>
to get the whole thing removed.

<form method="post" action="page2.asp" id="form1" name="form1">
<table>
<tr><td>Search:</td><td>
<select id="select1" name="select1">
<option Value="0">Select data</option>
<option Value="0">---------------------</option>
<option Value="1">Data 1</option>
<option Value="2">Data 2</option>
<option Value="3">Data 3</option>
</select></td></tr>
<tr><td>First Name:</td><td><INPUT type="text" id=text1
name="FName"></td></tr>
<tr><td>Last Name:</td><td><INPUT type="text" id=text2
name="LName"></td></tr>
<div id="mydiv"><tr><td>SSN:</td><td><INPUT type="text" id=text2
name="SSN"></td></tr></div>
</form>

<script language=vbscript>
sub select1_onchange()
    if document.form1.select1.value = 1 then
        document.mydiv.style.display = "none"
    end if
end sub
</script>


Quote:
> Is there a way to hide/show a row in a table when a user selects an item
> from an option list?  For instance, I know how to hide a textbox using the
> style.display property of the textbox, but that does not hide the text
that
> I have to the left of the textbox.  Here's what I've got:

> <form method="post" action="page2.asp" id="form1" name="form1">
> <table>
> <tr><td>Search:</td><td>
> <select id="select1" name="select1">
> <option Value="0">Select data</option>
> <option Value="0">---------------------</option>
> <option Value="1">Data 1</option>
> <option Value="2">Data 2</option>
> <option Value="3">Data 3</option>
> </select></td></tr>
> <tr><td>First Name:</td><td><INPUT type="text" id=text1
> name="FName"></td></tr>
> <tr><td>Last Name:</td><td><INPUT type="text" id=text2
> name="LName"></td></tr>
> <tr><td>SSN:</td><td><INPUT type="text" id=text2 name="SSN"></td></tr>
> </form>

> <script language=vbscript>
> sub select1_onchange()
>     if document.form1.select1.value = 1 then
>         document.form1.ssn.style.display = "none"
>     end if
> end sub
> </script>

> This will not remove the label "SSN:" from my form.  Is there a way to do
> this?  Thanks

> mike



Mon, 26 Nov 2001 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. table row text will not show after row insert

2. Hiding Table Rows

3. Getting row/column index of HTML TABLE cell

4. Using HTML table rows collection with VBScript

5. Anyway to Clear / Delete / Remove all rows from an HTML Table

6. Accesing cells in related rows in HTML table????

7. Color Changing in rows of HTML table.

8. Hidden table does show

9. Problem with dynamically created HTML table rows

10. How to show or hide a table row or text in NS and IE?

11. Hide and show hidden files with vb4 32-bit

12. How to open HTML file from VB6 code and let this HTML file show up

 

 
Powered by phpBB® Forum Software