onclick class assigment

This is a discussion on "onclick class assigment" within the JavaScript Forum section. This forum, and the thread "onclick class assigment are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > JavaScript Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Aug 27th, 2007, 12:08
Reputable Member
Join Date: May 2006
Location: Northampton, UK
Posts: 399
Thanks: 0
Thanked 0 Times in 0 Posts
onclick class assigment

hi guys,

I have an expanding menu that i want to spice up with an "open" background graphic.

the image swaps are all handled with CSS, and id like to keep it this way, problem is i can seem to figure out how to identify when a particular menu item is open, and therefore add the "over" graphic

heres my html at the moment,

im thinknig i need to add a class when the onclick is true, but my javascript is pants so you guys might tell me a better way, i hope

Code: Select all
<dl id="menu">
        <dt onclick="javascript:show('smenu1');"><a href="#">CD's and Music</a></dt>
            <dd id="smenu1">
                <ul>
                    <li><a href="#">MP3 Players</a></li>
                    <li><a href="#">CD's and Music</a></li>
                </ul>
            </dd>
            <dt onclick="javascript:show('smenu2');"><a href="#">Computing</a></dt>
            <dd id="smenu2">
                <ul>
                    <li><a href="#">Computers & Laptops</a></li>
                    <li><a href="#">Hardware</a></li>
                    <li><a href="#">Software</a></li>
                    <li><a href="#">Printers</a></li>
                    <li><a href="#">Satellite Navigation</a></li
                    <li><a href="#">MP3 Players</a></li>
                    <li><a href="#">Office Furnature</a></li>
                    <li><a href="#">Cameras</a></li>
                </ul>
            </dd>
            <dt onclick="javascript:show('smenu3');"><a href="#">DVD's and Video</a></dt>
            <dd id="smenu3">
                <ul>
                    <li><a href="#">DVD's</a></li>
                    <li><a href="#">DVD Rentals</a></li>
                </ul>
            </dd>
            <dt onclick="javascript:show('smenu4'); document.write('id="active"');"><a href="#">Electrical Goods</a></dt>
            <dd id="smenu4">
                <ul>
                    <li><a href="#">Home entertainment</a></li>
                    <li><a href="#">Satellite Navigation</a></li>
                    <li><a href="#">MP3 Players</a></li>
                    <li><a href="#">Kitchen Appliances</a></li>
                    <li><a href="#">Household Appliances</a></li>
                </ul>
            </dd>
</dl>
</div><!-- /leftdiv -->
you can see what im trying to do here :

Code: Select all
<dt onclick="javascript:show('smenu4'); document.write('id="active"');">
hope someone can help witht his

Accu
Reply With Quote

  #2 (permalink)  
Old Sep 1st, 2007, 16:54
Rakuli's Avatar
SuperMember

SuperMember
Join Date: Sep 2007
Location: Australia
Age: 24
Posts: 956
Blog Entries: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Re: onclick class assigment

I can think of a few ideas -- I'm not sure how well the document.write('id="action') will work, I can see a few problems with it.

Can you show the code for show('smenu4') is? Is that what is opening and closing the list?

Cheers
Last Blog Entry: The wannabe juggler's quest (Oct 27th, 2007)
Reply With Quote
Reply

Tags
onclick class

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 On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
createEmptyMovieClip & onclick R Verbrugge Flash & Multimedia Forum 7 Sep 13th, 2007 15:34
onClick and submit to new URL plooner PHP Forum 4 Feb 20th, 2007 21:40
OnClick to new URL and Submit together plooner JavaScript Forum 2 Feb 13th, 2007 11:48
Need help on an onclick function DaveKenroy JavaScript Forum 3 Jan 28th, 2007 11:31
onclick function tomd1985 JavaScript Forum 0 Mar 13th, 2006 18:20


All times are GMT. The time now is 06:00.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43