View Full Version : "On Click" <--Two Instructions at the same time?

07-12-2007, 08:44 PM
<div href="javascript:void(0)" class="menu_button" onClick="openDiv('t2');">Food & Drink</div>
<div id="t2" style="display:none;">

^ here is the code i have got for a drop down menu.

When somebody clicks on it, i want the css style to change...I cant seem to do this as onClick is already being used :S

07-12-2007, 09:05 PM
Iím not the baddest JS pro but I think you can without problems fire more than one functions in the event handler.

onclick="function1(); function2(); return false;">link</a>

And by the way: http://blog.reindel.com/2006/08/11/a-hrefjavascriptvoid0-avoid-the-void/

07-12-2007, 09:52 PM
onclick="function1(openDiv('t2')">); function2(simple_menu); return false;">link</a>

^^ i did that but no luck

07-12-2007, 09:55 PM
That was just an example.

onclick="openDiv('t2'); simple_menu(); return false;">link</a>

07-12-2007, 09:58 PM

^^ thts the link..It stil dont seem to work :S

07-12-2007, 10:10 PM
It would help if you actually had good html. Your coding is awful.
You have this

<div class="menu_button" onclick="openDiv('t2'); simple_menu(); return false;">link</a> href="javascript:void(0)">Finance &amp; Legal Services</div>

change it to this

<div class="menu_button" onclick="openDiv('t2');">Finance &amp; Legal Services</div>

Now that we got that straightened out. What exactly are you trying to do? You have no simple_menu() function. What styles do you want to apply to the divs? I see you already have class="simple_menu" on the divs. Can you not just use that?

07-12-2007, 10:44 PM
When a user clicks on the button, i want its sub-buttons to open up, whilst the first buttons changes its style..When clickd upon.