我想从数组中获取每个值,当我选择或检查每个值时,我只想获取一个值。但是有一些错误,我不知道如何修复它。我该如何解决它才能正常工作?请告诉我。谢谢
var pzArray = [];
function pizzaOrder() {
var orderList = {
pizzaName:"",
size:"",
topping:""
};
orderList.pizzaName = document.getElementById("pzName").value;
orderList.size = document.getElementByName("pzSize").value;
orderList.topping = document.getElementById("topping").checked;
pzArray.push(orderList);
for (var i = 0; i<pzArray.length; i++) {
var pizza = pzArray[i];
invoice = pizza.size + pizza.pizzaName + pizza.topping;
totalInvoice += invoice + "<br>"
}
document.getElementById("showList").innerHTML = totalInvoice;
}
<body>
<div>
<input type=radio id="pzName" name=pzSelect value="A">a
<input type=radio id="pzName" name=pzSelect value="B">b
<input type=radio id="pzName" name=pzSelect value="C">c
<br><br>
<select>
<option name="pzSize" id="small" value="Small">S
<option name="pzSize" id="medium" value="Medium">M
<option name="pzSize" id="large" value="Large">L
</select>
<br><br>
<input type="checkbox" id="topping" name="ExtraCheese" value="Extra Cheese">XtraC
<input type="checkbox" id="topping" name="Pepperoni" value="Pepperoni">P
<input type="checkbox" id="topping" name="Mushrooms" value="Mushrooms">M
<br><br>
<input type=button value="Order Description" onClick="pizzaOrder()" />
</div>
<span id="showlist"><span></span>
</body>
ABOUTYOU
吃鸡游戏
相关分类