I want determine the value of textbox based on the previous textbox using JavaScript, But the code it’s not work.
Here the javascript
function result_method(){
var bw_method =document.getElementById("bw_method");
var w_method = document.getElementById("w_method");
var result_method = document.getElementById("result_method");
if (!isNaN(bw_method.value="Accepted", w_method.value="Accepted")){
document.querySelector('[name="result_method"]').value = "Pass";
}else{
document.querySelector('[name="result_method"]').value="Fail";
}
}
<label> Before Wash </label>
<select name="bw_method" id="bw_method" class="form-control" onkeyup="result_method();" disabled>
<option selected >PILIH</option>
<option value="Accepted">Accepted</option>
<option value="Rejeceted">Rejected</option>
</select>
<label> 1. wash </label>
<select name="w_method" id="w_method" class="form-control" onkeyup="result_method();">
<option selected disabled>PILIH</option>
<option value="Accepted">Accepted</option>
<option value="Rejected">Rejected</option>
</select>
<label> Result </label>
<input name="result_method" id="result_method" type="text" class="form-control" readonly>
Please help me, thankyouuuu
2
Answers
I think your javascript function is if the condition syntax is incorrect try to below.
Try this one
Please check following working demo, there were issues in condition and its passed values,