toggle node with checkbox

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • student4lifer@gmail.com

    toggle node with checkbox

    Hello,

    I currently have a hyperlink to toggle the node, showing and hiding
    the list. Could someone show me how to use a checkbox instead of the
    hyperlink to do the same thing? Thanks.


    I tried the following line but the node's nextSibling becomes
    [<u>Fruits:</u>] instead of <div>. Then I tried node.
    nextSibling.nex tSibling but it didn't work. Please help!

    <input type="checkbox" onclick="Toggle (this)" id="Fruits"><u> Fruits:</
    u><div>

    ===========

    <html>

    <script language="JavaS cript">

    function Open(node)
    {

    node.nextSiblin g.style.display = '';
    }

    function Close(node)
    {

    node.nextSiblin g.style.display = 'none';
    }

    function Toggle(node)
    {

    if (node.nextSibli ng.style.displa y == 'none')
    {
    Open(node);
    }

    else
    {
    Close(node);
    }

    }

    </script>
    <a onclick="Toggle (this)" id="Fruits"><u> Fruits:</u></a><div>
    <table>
    <tr>
    <td>Orange</td>
    <td>Apple</td>
    <td>Pearl</td>
    </tr>
    </table>
    </div>

    </html>
  • Conrad Lender

    #2
    Re: toggle node with checkbox

    On 2008-10-12 07:23, student4lifer@g mail.com wrote:
    I currently have a hyperlink to toggle the node, showing and hiding
    the list. Could someone show me how to use a checkbox instead of the
    hyperlink to do the same thing? Thanks.
    >
    >
    I tried the following line but the node's nextSibling becomes
    [<u>Fruits:</u>] instead of <div>. Then I tried node.
    nextSibling.nex tSibling but it didn't work. Please help!
    node.nextSiblin g.nextSibling will work if you change it in all three
    functions.

    Before you wonder your script isn't working as expected, check your
    HTML. What you're using in your test isn't remotely valid:
    W3C's easy-to-use markup validation service, based on SGML and XML parsers.



    - Conrad

    Comment

    Working...