The HTML:
<select id="SHIELD" onchange="calcCHO();" >
<option value="610" selected >CHO-SHIELD 610</option>
<option value="608" >CHO-SHIELD 608</option>
<option value="604" >CHO-SHIELD 604</option>
</select>
<input id="FILLER" type="text" disabled value="" />
The Script:
function calcCHO(){
var f_S = "Silver";
var f_N = "Nickel";
var f_SC = "Silver/Copper";
var CHOS = document.getElementById("SHIELD").value;
var FILLER = document.getElementById("FILLER").value;
if(CHOS === "610") {
FILLER = f_S;
}
else if (CHOS === "608") {
FILLER = f_N;
}
else {
FILLER = f_SC;
}
}
This looks pretty straightforward, any idea why it does not work or produce any console errors?
Thanks!
try it like that.
function calcCHO(){
var f_S = "Silver";
var f_N = "Nickel";
var f_SC = "Silver/Copper";
var CHOS = document.getElementById("SHIELD").value;
var FILLER = document.getElementById("FILLER");
if(CHOS === "610") {
FILLER.value = f_S;
}
else if (CHOS === "608") {
FILLER.value = f_N;
}
else {
FILLER.value = f_SC;
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.