User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 331,627 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 4,200 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting

javascript onclick is not working in IE7 & IE6

Join Date: Apr 2008
Posts: 2
Reputation: aheman is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
aheman aheman is offline Offline
Newbie Poster

Re: javascript onclick is not working in IE7 & IE6

  #6  
Apr 10th, 2008
plazmo is right about that. In IE6/7 (no idea about later versions) options can't really have individual onclick statements. However, a quick workaround can be put together.

Starting code...
<select>
     <option onclick="my javascript"></option>
     <option onclick="my javascript"></option>
     <option onclick="my javascript"></option>
</select>

In order to get that working, just change the onclicks to values, and add the onchange handler eval(this.value) and it will function almost identical to an onclick.

<select onchange="eval(this.value);">
     <option value="my javascript"></option>
     <option value="my javascript"></option>
     <option value="my javascript"></option>
</select>

It's the fastest way I know to make option onclick work in IE and Mozilla.
Reply With Quote  
All times are GMT -4. The time now is 12:32 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC