Here is one for you

This is (should be) cross browser.  Works in Firebird, IE and Netscape

Below is a table with 5 rows.  By selecting the row you want from the slect
box you can show or hide the row in question


<script>
        function toggleRow(obj)
                {
                obj.style.display = obj.style.display == "none" ? "" : "none";

                // Or accessing the actual TD cells
                //for (i=0; i < obj.cells.length; ++i)
                //      {obj.cells[i].style.display = obj.cells[i].style.display == 
"none" ? ""
: "none";}
                }
</script>
<select id="rowItem">
        <option value="1">1</option>
        <option value="2">2</option>
        <option value="3">3</option>
        <option value="4">4</option>
        <option value="5">5</option>
</select>
<input type="Button" onclick="toggleRow(document.getElementById('item' +
document.getElementById('rowItem').value))" value="click"><br>
<table border="1">
        <tr id="item1"><td>this is row 1</td></tr>
        <tr id="item2"><td>this is row 2</td></tr>
        <tr id="item3"><td>this is row 3</td></tr>
        <tr id="item4"><td>this is row 4</td></tr>
        <tr id="item5"><td>this is row 5</td></tr>
</table>

Steve




-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of Stephen
Bosworth
Sent: Wednesday, June 02, 2004 10:11 AM
To: CFAussie Mailing List
Subject: [cfaussie] Re: OT: DIV's and Visibilty


Yeah, I realised that, I just cut'n'pasted the code that was given, and
wrapped a js function around it.

Cheers,
Steve

--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Stephen Bosworth
Application Development and Integration
Communication and Information Services
The University of Newcastle, Australia
Phone: 02 4921 6574
Fax: 02 4921 7087
Mobile: 0438 492518
Email: [EMAIL PROTECTED]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

>>> [EMAIL PROTECTED] 06/01/04 05:31pm >>>
Hi Stephen,

This is invalid HTML and therefore not advisable. You simply can't put the
DIV outside the TR and TD yet within the TABLE. I would suggest maybe
putting the style and id onto the TR element instead, or better still
setting a class (or ID if you only use it once per page) in your stylesheet
and using that.

> to hide:
>
> <DIV id="ANAETHESTIC_TIMES" style=" display:none;">
>       <TR>
>               <TD>Start Time</TD>
>               <TD>&nbsp;</TD>
>               <TD><INPUT type="TEXT" name="START_TIME" VALUE=""></TD>
>       </TR>
> </DIV>

This is a result from the WDG Validator
http://www.htmlhelp.com/tools/validator/direct.html

Errors and Warnings

Line 11, character 52:
... times" style="display: none;">
                                 ^Error: element DIV not allowed here; check
which elements this element may be contained within
(http://www.htmlhelp.com/reference/html40/block/div.html)

Line 12, character 6:
                <tr>
                   ^Error: element TR not allowed here; check which elements
this element may be contained within
(http://www.htmlhelp.com/reference/html40/tables/tr.html)

Input
 1   <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
 2
 3   <html>
 4   <head>
 5      <title>Untitled</title>
 6   </head>
 7
 8   <body>
 9
10   <table>
11      <div id="anaethestic_times" style="display: none;">
12              <tr>
13                      <td>Start Time</td>
14                      <td>&nbsp;</td>
15                      <td><input type="TEXT" name="START_TIME"
value=""></td>
16              </tr>
17      </div>
18      <tr>
19              <td>Start Time</td>
20              <td>&nbsp;</td>
21              <td><input type="TEXT" name="START_TIME" value=""></td>
22      </tr>
23   </table>
24
25   </body>
26   </html>

Regards,

Peter




---
You are currently subscribed to cfaussie as:
[EMAIL PROTECTED]
To unsubscribe send a blank email to [EMAIL PROTECTED]

MXDU2004 + Macromedia DevCon AsiaPac + Sydney, Australia
http://www.mxdu.com/ + 24-25 February, 2004


---
You are currently subscribed to cfaussie as: [EMAIL PROTECTED]
To unsubscribe send a blank email to [EMAIL PROTECTED]

MXDU2004 + Macromedia DevCon AsiaPac + Sydney, Australia
http://www.mxdu.com/ + 24-25 February, 2004


---
You are currently subscribed to cfaussie as: [EMAIL PROTECTED]
To unsubscribe send a blank email to [EMAIL PROTECTED]

MXDU2004 + Macromedia DevCon AsiaPac + Sydney, Australia
http://www.mxdu.com/ + 24-25 February, 2004

Reply via email to