toggle node with checkbox

Discussion in 'Javascript' started by student4lifer@gmail.com, Oct 12, 2008.

  1. Guest

    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.nextSibling but it didn't work. Please help!

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

    ===========

    <html>

    <script language="JavaScript">

    function Open(node)
    {

    node.nextSibling.style.display = '';
    }

    function Close(node)
    {

    node.nextSibling.style.display = 'none';
    }

    function Toggle(node)
    {

    if (node.nextSibling.style.display == '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>
    , Oct 12, 2008
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    0
    Views:
    1,399
  2. Tjerk Wolterink
    Replies:
    2
    Views:
    1,399
    Dimitre Novatchev
    Aug 24, 2006
  3. Aung

    checkbox toggle

    Aung, Apr 9, 2004, in forum: ASP .Net Datagrid Control
    Replies:
    4
    Views:
    157
    Ian Oldbury
    Apr 14, 2004
  4. Stanimir Stamenkov

    [IE] Toggle checkbox state - onclick vs. onchange

    Stanimir Stamenkov, Apr 4, 2008, in forum: Javascript
    Replies:
    0
    Views:
    145
    Stanimir Stamenkov
    Apr 4, 2008
  5. ameshkin
    Replies:
    4
    Views:
    146
    Dr J R Stockton
    Jul 22, 2008
Loading...

Share This Page