Reputation: 4389
I have a "Save Settings" button which is of type 'image'. I want it to be enabled only after a checkbox is checked by the user I m using..
$('#btnSaveProfile').attr("disabled",true);
$('#btnSaveProfile').click(function(){
if ($("#rdAccept").is(':checked'))
{
$('#btnSaveProfile').attr("disabled",false);
updateProfile();// calling a function here that saves data.
}
});
This does not work, any inputs....please
Upvotes: 0
Views: 1851
Reputation: 78667
You are not using the checkbox click event, try the following
var $btn = $('#btnSaveProfile').attr("disabled",true);
$('#rdAccept').click(function(){
if (this.checked) {
$btn.removeAttr("disabled");
}
});
$btn.click(updateProfile);
Upvotes: 1
Reputation: 36999
You are disabling the element with id btnSaveProfile
and then attaching a click handler, which will never get run because its disabled. You need to add a click handler to your checkbox, which will re-enable the save button.
Upvotes: 2
Reputation: 3937
$('#btnSaveProfile').attr("disabled",'');
enables the button
$('#btnSaveProfile').attr("disabled",'disabled');
disables the button
Upvotes: 1