A problem doing my head in. I'm using .Net MVC.
In my view I have the following three fields.
<div class="form-group">
<div class="col-md-10">
</div>
</div> ///This is a drop down
<div class="form-group">
<div class="col-md-10">
<div class="checkbox">
</div>
</div>
</div> //// This is a checkbox
<div class="form-group">
<div class="col-md-10">
</div>
</div> /// This is a text field
So if the checkbox is unchecked I call a controller view to populate. If the checkbox is checked I just want it to display 'NONE'
My Java script code is.
$('#PHYSID').click(function() {
var Phys_isChecked = $('#PHYSID').is(':checked');
var Env_selectedVal = $("#EnvID").val();
var OPP_SelectedVal = '@(ViewBag.OppID)';
if (Phys_isChecked = "true") {
$('#CLUSTERID').val("NONE");
}
else {
$.ajax({
type: "POST",
url: "../OPP_Landscape/GetClusterName",
data: { OPPID: OPP_SelectedVal, ENV: Env_selectedVal },
cache: false,
dataType: "json",
success: function (Cluster) { $('#CLUSTERID').val(Cluster); }
});
};
});
$('#EnvID').change(function() {
var Env_selectedVal = $("#EnvID").val();
alert(Env_selectedVal);
var OPP_SelectedVal = '@(ViewBag.OppID)';
alert(OPP_SelectedVal);
var Phys_isChecked = $('#PHYSID').is(':checked');
alert(Phys_isChecked);
if (Phys_isChecked = 'false') {
$.ajax({
type: "POST",
url: "../OPP_Landscape/GetClusterName",
data: { OPPID: OPP_SelectedVal, ENV: Env_selectedVal },
cache: false,
dataType: "json",
success: function (Cluster) { $('#CLUSTERID').val(Cluster); }
});
} else if (Phys_isChecked= 'true') {
alert("Not Checked");
$('#CLUSTERID').val("NONE");
};
});
Now the code seems to work, but if I change the checkbox to checked, it fills in the text field with 'None' as expected but if I then change the dropdown it still fills in the textbox even though the if statement is true?
Comments
Feedback
Cheers (why can't equals syntax be common across languages)