基本上,我想在用户输入的计算中使用下拉列表值,但是当我添加下拉值时,它是NaN或者没有给出任何值。我确实尝试计算基于索引选择和值更改为整数但不起作用。任何帮助将不胜感激
<div id="stock" style="padding-top:15px">
<label>Text Stock</label>
<select name="textStock" id="textStock">
<option value="None">Select Stock</option>
<option value="50gsm">50gsm(£0.10)</option>
<option value="120gsm">120gsm(£0.15)</option>
<option value="150gsm">150gsm(£0.20)</option>
<option value="200gsm">200gsm(£0.30)</option>
<option value="250gsm">250gsm(£0.40)</option>
</select>
</div>
评论位是我尝试过的最后一次无法正常工作
var textStock = new Array();
textStock["None"] = 0;
textStock["50gsm"] = 0.10;
textStock["120gsm"] = 0.20;
textStock["150gsm"] = 0.30;
textStock["200gsm"] = 0.40;
textStock["250gsm"] = 0.50;
/* var stockPrice = 0;
var text_stock = document.getElementById(textStock).value;
var form = document.forms["form"];
var selected = form.elements["textStock"];
var val = textStock[selected.value]; */
var express = document.getElementById("express");
var standard = document.getElementById("standard");
if (express.checked) {
if (productQuantity > 50 && productQuantity < 500) {
discountPrice = (productQuantity * basePrice) * 0.25;
// stockPrice = val * productQuantity;
total = (basePrice * productQuantity) - discountPrice;
//var totalPrice = total + stockPrice;
alert("Express delivery applied, please expect your order within 2 working days\nTotal Price is: £" + total)
}
答案 0 :(得分:0)
有点不清楚你想要什么,但这应该给你基于所选选项的价值。
delBtn.addTarget(self, action: #selector(FavViewController.DelFavAction(_:)), forControlEvents: .TouchUpInside)