Tuesday, 15 March 2011

javascript - Hide/Show is not working in IE 8 -



javascript - Hide/Show is not working in IE 8 -

i having 2 dropdowns. based on first dropdown values, sec dropdown values hidden. hide() , show() not working in ie 8. working fine in firefox.

code:

<script type="text/javascript"> function marketcd_dropdown_const(){ alert($("#first").val()); switch ($("#first").val()) { case 'one': $('.market_code_dropdown').hide(); $('.instorder').hide(); $('#all_option').prop('selected',true); break; case 'two': $('.market_code_dropdown').hide(); $('.instorder').hide(); $('#all_option').prop('selected',true); break; default: $('.market_code_dropdown').show(); $('.instorder').show(); $('#all_option').prop('selected',true); break; } } $(document).ready(function(){ alert("ready function"); $(document).bind('change', ".first_class", marketcd_dropdown_const); }); </script>

jsp:

<select name=billingsystem id="first" class="first_class" size="1" onchange="nuvoxcolumn(this);" > <!-- // alternative --> <option value=<%= m_strall %> <% if (m_bget || m_stroldbillingsystem.equals("%")) {%> <%= m_selected %> <%} %> > <%= m_strallsearch %> <%log.write("m_strallsearch billing system: "+m_strallsearch); %> </option> <% while(m_strbillsystemlist[icount] != null) { string strbillsystem = m_strbillsystemlist[icount]; %> <option value=<%= strbillsystem %> <%log.write("m_stroldbillingsystem: "+m_stroldbillingsystem); %> <% if (m_stroldbillingsystem != null) { if (m_stroldbillingsystem.equals(strbillsystem)) {%> <%= m_selected %> <%} } %> > <%= strbillsystem %> <%log.write("strbillsystem: "+strbillsystem); %> </option> <% icount++; } %> </select> <select name=marketcode id="second" size = 1> <!-- // alternative --> <option id="all_option" value=<%= m_strall %> <% if (m_bget || m_stroldmarketcode.equals("%")) {%> <%= m_selected %> <%} %> > <%= m_strallsearch %> <%log.write("m_strallsearch market code: "+m_strallsearch); %> </option> <% while(m_strmktcodelist[icount] != null) { string strmktcode = m_strmktcodelist[icount]; %> <option class="market_code_dropdown" value=<%= strmktcode %> <% if (m_stroldmarketcode != null) { if (m_stroldmarketcode.equals(strmktcode)) {%> <%= m_selected %> <%} } %> > <%= strmktcode %> <%log.write("strmktcode: "+strmktcode); %> </option> <% icount++; } %> </select>

jquery version used:jquery v1.4.2 afterwords, used latest jquery version. both not working in ie 8.

i think need alter code according latest jquery version ...

$(document).ready(function(){ alert("ready function"); $(document).on('change', ".first_class", marketcd_dropdown_const); });

or can utilize jqueyr migration plugin back upwards old version code

i run code , working... check it..

<script type="text/javascript"> function marketcd_dropdown_const(){ alert($("#first").val()); switch ($("#first").val()) { case 'one': $('.market_code_dropdown').hide(); // $('.instorder').hide(); // $('#all_option').prop('selected',true); break; case 'two': $('.market_code_dropdown').hide(); // $('.instorder').hide(); // $('#all_option').prop('selected',true); break; default: $('.market_code_dropdown').show(); // $('.instorder').show(); // $('#all_option').prop('selected',true); break; } } $(document).ready(function(){ alert("ready function"); $(document).bind('change', ".first_class", marketcd_dropdown_const); }); </script> <body> <select name=billingsystem id="first" class="first_class" size="1" > <!-- // alternative --> <option value="" >select</option> <option value="one" >test</option> <option value='two'>test1 </option> </select> <select name="marketcode" id="second" size = "1" class="market_code_dropdown"> <option value="" >test</option> <option value='tt'>test1 </option> </select> </body>

use javascript version...

<script type="text/javascript"> function marketcd_dropdown_const(obj){ switch (obj.value) { case 'one': document.getelementbyid('second').style.display = 'none'; // $('.instorder').hide(); // $('#all_option').prop('selected',true); break; case 'two': document.getelementbyid('second').style.display = 'none'; // $('.instorder').hide(); // $('#all_option').prop('selected',true); break; default: document.getelementbyid('second').style.display = 'block'; // $('.instorder').show(); // $('#all_option').prop('selected',true); break; } } </script> <body> <select name=billingsystem id="first" class="first_class" size="1" onchange=" marketcd_dropdown_const(this)" > <!-- // alternative --> <option value="" >select</option> <option value="one" >test</option> <option value='two'>test1 </option> </select> <select name="marketcode" id="second" size = "1" class="market_code_dropdown"> <option value="" >test</option> <option value='tt'>test1 </option> </select> </body>

javascript jquery

No comments:

Post a Comment