我有一些jquery可以防止在勾选复选框时更改几个选择字段。这工作没问题,但我似乎无法解除工作。当取消勾选复选框时,我需要选择再次工作。
$("input#same").live('click', function () {
if ($("input#same").is(':checked')) {
// Checked, copy values
$("input#shipping_first_name").val($("input#first_name").val()).attr("readonly", true);
$("input#shipping_last_name").val($("input#last_name").val()).attr("readonly", true);
$("input#shipping_address").val($("input#address").val()).attr("readonly", true);
$("input#shipping_address2").val($("input#address2").val()).attr("readonly", true);
$("input#shipping_city").val($("input#city").val()).attr("readonly", true);
$("select#shipping_state").val($("select#state").val()).bind("change", function () {
$("select#shipping_state").val($("select#state").val())
});
$("input#shipping_zip").val($("input#zip").val()).attr("readonly", true);
$("select#shipping_country_code").val($("select#country_code").val()).bind("change", function () {
$("select#shipping_country_code").val($("select#country_code").val())
});
} else {
// Clear on uncheck
$("input#shipping_first_name").val("").removeAttr("readonly");
$("input#shipping_last_name").val("").removeAttr("readonly");
$("input#shipping_address").val("").removeAttr("readonly");
$("input#shipping_address2")..val("").removeAttr("readonly");
$("input#shipping_city").val("").removeAttr("readonly");
$("select#shipping_state").val("").unbind("change");
$("input#shipping_zip").val("").removeAttr("readonly");
$("select#shipping_country_code").val("").unbind("change");
}
});
$('#order').live('submit', function () {
$('input[type=submit]', this).attr('disabled', 'disabled');
});
});