views:

28

answers:

2

I have a dropdown menu and I want to disable/enable a button on my page when a certain value is selected. It works in All browsers but IE7 and below. Work around????

Code:

<script type="text/javascript">
$(document).ready(function() {

//Start Buttons
        $(".nextbutton").button({ disabled: true });
        (".nextbutton").click(function() { $("#phonetypeform").submit() });

//Enable Next Step
    $('.enablenext').click(function(){
            $(".nextbutton").button("enable");
                }); 

//Disable Next Step
    $('.disablenext').click(function(){
            $(".nextbutton").button("disable");
                }); 

});
</script>

<form>
      <select name="porting-p1"class="dropdown">
<option value="" class="disablenext">Please select an option...</option>
<option value="1" class="enablenext">I want to keep my current phone number</option>
<option value="2" class="enablenext">I want to choose a new number</option>
        </select>

</form>

<button class="nextbutton">Next Step</button> 
A: 

Have you tried

$(".nextbutton").attr("disabled", "disabled");

and

$(".nextbutton").removeAttr("disabled");

?

HTH

DannyLane
+1  A: 

IE7 doesn't seem to like the click event on <option> tags.

Here's a short demo that should work for you using the change() event instead.

$(document).ready(function() {

    $(".nextbutton").button({ disabled: true });

    $('.dropdown').change(function() {
        if ($('.dropdown').val() == 0) {
            $(".nextbutton").button({ disabled: true });
        } else {
            $(".nextbutton").button({ disabled: false });
        }
    });

});
irishbuzz