I am trying to get jQuery to disable the confirmation button in my form if the dropdown is a specific value, but it doesn't seem to work.
I read a lot of posts here and tried different ways.
Here is my code at the moment:
<script>
$(document).ready(function () {
$('#MoveToCompanyId').attr("disabled", true);
$('#DeleteAll').live("click", function () {
if ($(this).attr("value") == "True") {
$('#MoveToCompanyId').attr("disabled", true);
} else {
$('#MoveToCompanyId').attr("disabled", false);
$('#confirm').attr("disabled", true);
$('#MoveToCompanyId').change(function () {
if ($("#MoveToCompanyId option:selected").text() != "---Select Company---") {
$('#confirm').removeAttr("disabled");
alert($("#MoveToCompanyId option:selected").text());
}
else {
$('#confirm').attr("disabled", true);
alert("I should be disabled!");
}
});
}
});
});
</script>
Can anyone see any problems with it?
Just to clarify, I know that it falls into the correct blocks of code, since my warnings work. Its just a shutdown button that doesn't work.
Yours faithfully,
Gareth
source
share