0

JavaScript CSS styling not working in IE, it is working in Chrome and Mozilla.

This is my code:

document.ready=function() {
        var val = document.getElementById("registration_select").value;
        if(val =="Relay - Ultra, Standard and Sprint distances (Men / Women/ Mixed) - open to all Age-Groups & Juniors above 16"){            
        document.getElementById("register_right").style.display="block";
        }
        else{            
        document.getElementById("register_right").style.display="none";
        }

 registration_select.onchange=function(){
        var val = document.getElementById("registration_select").value;
        if(val =="Relay - Ultra, Standard and Sprint distances (Men / Women/ Mixed) - open to all Age-Groups & Juniors above 16"){            
        document.getElementById("register_right").style.display="block";
        }
        else{            
        document.getElementById("register_right").style.display="none";
        }
     }
};

This is my HTML

<select id="registration_select" name="Category">
<option value="category1">category1</option>
<option value="Relay - Ultra, Standard and Sprint distances (Men / Women/ Mixed) - open to all Age-Groups & Juniors above 16">Relay - Ultra, Standard and Sprint distances (Men / Women/ Mixed) - open to all Age-Groups & Juniors above 16</option>
</select>

<div id="register_right">

<h3>Team Mate Profile</h3>

</div>

And this is my CSS

#register_right{float:right;  display:none; width:49%;}

Please Help.

9
  • plz show the html also..and make sure there is no duplicate id's in your html. Commented Oct 1, 2014 at 5:14
  • 6
    Do not see any jquery here. Commented Oct 1, 2014 at 5:15
  • 1
    just a suggestion... javascript is case sensitive you are compairing a long string in if statememt ... so just convert left and right hand side to lowercase and then check whether they are equal or not. Commented Oct 1, 2014 at 5:20
  • Jquery has left the building. Your code has no jquery in it! Commented Oct 1, 2014 at 5:21
  • 1
    jsfiddle.net/89epLxao Check this. Working fine in IE10 and Chrome Commented Oct 1, 2014 at 5:45

1 Answer 1

1

Try this

 jQuery(function($) {
        var val = document.getElementById("registration_select").value;

            if(val =="Relay - Ultra, Standard and Sprint distances (Men / Women/ Mixed) - open to all Age-Groups & Juniors above 16"){            
                document.getElementById("register_right").style.display="block";
            }
            else{            
                document.getElementById("register_right").style.display="none";
            }

            document.getElementById("registration_select").onchange=function(){
                var val = document.getElementById("registration_select").value;
                if(val =="Relay - Ultra, Standard and Sprint distances (Men / Women/ Mixed) - open to all Age-Groups & Juniors above 16"){            
                    document.getElementById("register_right").style.display="block";
                }
                else{            
                    document.getElementById("register_right").style.display="none";
                }
            }

    });
Sign up to request clarification or add additional context in comments.

1 Comment

@AasimHussainKhan : in your code, registration_select was undefined.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.