Reputation: 69
I have a custom part builder and I have it so when a customer selects the option "Full" it executes this script
$(function() {
$("input[name='FirstFlangeSystem']").on("change", function(e) {
var newValue = e.target.value;
$("input[name='SecondFlangeSystem'][value='" + newValue + "']").prop("checked", true);
});
$("select[name='FirstFlangeTypeDrop']").on("change", function(e) {
var newValues = $(this).val();
$("select[name='SecondFlangeTypeDrop']").val(newValues);
});
document.getElementById("SecondFlangeTypeDrop").disabled = true;
});
The problem is if you select the "Full" option then you select one of the other 2 options "Half" or "Adapter" the function is still running. How do I get it to stop?
Upvotes: 0
Views: 50
Reputation: 1603
You can disable these fields. If .Half
and .Adapter
are something like checkbox, then it can be done like that.
var $half = $(".Half");
var $adapter = $(".Adapter");
$(".Half, .Adapter").on("change", function(e){
if($half.prop("checked") || $adapter.prop("checked")){
$("input[name='FirstFlangeSystem']").prop( "disabled", true );
$("input[name='FirstFlangeSystem']").prop( "disabled", true );
}else{
$("input[name='FirstFlangeSystem']").prop( "disabled", false );
$("input[name='FirstFlangeSystem']").prop( "disabled", false );
}
}
Upvotes: 1