Monday, September 29, 2008

[jQuery] Confirm, then change back value

I am trying to change a select list, and if the user sets it to No,
then a confirm dialog comes up, if they hit cancel, the value will get
set back to Yes.

For some reason it is not working:

$("#metadata_field_text_33100_value").change(function() {
var confirmWeb = confirm("Are you sure that you don't
want this Announcement to be posted on the website?");
if ($(this).val() == "No" || confirmWeb) {
return true;
}
else {
$("#metadata_field_text_33100_value").val("Yes");
}
});

No comments: