这是我的 HTML 代码:
<select id="stand" onchange="myFun2()">
<option value="platinumGallery">Platinum Gallery</option>
<option value="superHospitalityStand">Super Hospitality Stand</option>
<option value="northWestStand">North West Stand</option>
<option value="eastStand">East Stand</option>
</select><br><br>
<label>Cost Of Ticket: </label>
<input id="costOfTicket" type="text" readonly>
和JS代码:
function myFun2(){
var costOfTicket;
var selectedStand = document.getElementById("stand").value;
if(selectedStand = "platinumGallery"){
costOfTicket = 25000;
}
else if(selectedStand = "superHospitalityStand"){
costOfTicket = 20000;
}
document.getElementById("costOfTicket").value = costOfTicket;
}
每当onchange()事件发生时,我想Cost Of Ticket根据选择的值进行显示select。但它会在事件发生25000后显示onchange(),然后无论选择的值如何都不会改变。如何修正代码来完成上述任务?
尚方宝剑之说
慕侠2389804
相关分类