•
•
•
•
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,630 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,150 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
Views: 2235 | Replies: 5
![]() |
| |
•
•
Join Date: Mar 2008
Posts: 3
Reputation:
Rep Power: 0
Solved Threads: 0
hi guys ,
im facing a small problem with javascript,it works fine in FF,but inIE6 & IE7 nothing is happening could anyone solve this problem....plz help me.
Here is the HTML code:
Here is the JavaScript code:
im facing a small problem with javascript,it works fine in FF,but inIE6 & IE7 nothing is happening could anyone solve this problem....plz help me.
Here is the HTML code:
<div id="div1" style="display: visible">Div 1</div>
<select>
<option onclick="javascript:changeDisplay('div1','block')">visible</option>
<option onclick="javascript:changeDisplay('div1','none')">hidden</option>
</select> Here is the JavaScript code:
<script type="text/javascript">
function changeDisplay(elem,displayMode){
document.getElementById(elem).style.display = displayMode;
}
</script> If the script keeps running (e.g. if there is a loop we can't see, or another script), the display won't change. IE waits until the script ends to update the screen.
Block and none are not valid display modes. Use visible and hidden.
Block and none are not valid display modes. Use visible and hidden.
Last edited by MidiMagic : Mar 25th, 2008 at 3:16 am.
Daylight-saving time uses more gasoline
•
•
Join Date: Mar 2008
Posts: 3
Reputation:
Rep Power: 0
Solved Threads: 0
•
•
•
•
If the script keeps running (e.g. if there is a loop we can't see, or another script), the display won't change. IE waits until the script ends to update the screen.
Block and none are not valid display modes. Use visible and hidden.
thank u for response
but still it's not working...
if possible can u send me the code plz its urgent
once again thank u
•
•
Join Date: Mar 2008
Posts: 37
Reputation:
Rep Power: 1
Solved Threads: 3
i have used none and single quotes and it works in both IE and firefox
like this
like this
var el = document.getElementById(obj);
var butId = document.getElementById(buttonId);
if ( el.style.display != 'none' )
{
el.style.display = 'none';
butId.value='Show Filter';
document.getElementById("FilterResultsList").style.display = '';
}else {
el.style.display = '';
butId.value='Hide Filter';
document.getElementById("FilterResultsList").style.display = 'none';
} the problem is you cant put an event on a option in IE as far as i know.
so the best solution is to put the event on the select
so the best solution is to put the event on the select
<div id="div1" style="display: visible">Div 1</div>
<select onchange="changeDisplay('div1',this.options[this.selectedIndex].value)">
<option value="block">visible</option>
<option value="none">hidden</option>
</select> Last edited by plazmo : Mar 28th, 2008 at 9:50 am.
•
•
Join Date: Apr 2008
Posts: 2
Reputation:
Rep Power: 0
Solved Threads: 0
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...
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.
It's the fastest way I know to make option onclick work in IE and Mozilla.
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.
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb Marketplace (Sponsored Links)
•
•
•
•
age amd avatar blue gene business chips development dos economy energy enterprise environment explorer firefox gradient graphics hardware html ibm ibm. news ie ie7 ie8 intel ibm internet internet explorer internet explorer 8 it javascript linux medicine memory microsoft news open source openoffice pc ps3 recession red hat remote working russia sun supercomputer supercomputing technology trends ubuntu working x86
- Previous Thread: javascript for enabling and disabling
- Next Thread: Dynamically add rows to a form



Hybrid Mode