Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old October 12th, 2008, 06:25 AM
student4lifer@gmail.com
Guest
 
Posts: n/a
Default 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.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>
  #2  
Old October 12th, 2008, 07:55 AM
Conrad Lender
Guest
 
Posts: n/a
Default Re: toggle node with checkbox

On 2008-10-12 07:23, student4lifer@gmail.com wrote:
Quote:
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!
node.nextSibling.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:
http://validator.w3.org/


- Conrad
 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles