javascript - dropdown list with user input calculation -


basically, want use dropdown list value in calculation user input, when add dropdown value it's either nan or not giving value. did try calculate based on index select , value change integer did not work. appreciated

<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> 

the commented bit last working tried didn't work

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 order within 2 working days\ntotal price is: £" + total)      } 

it's bit unclear wanting should give value based on selected option.

var text_stock = document.getelementbyid("textstock").value; var val = textstock[text_stock]; //if "120sgm" selected, val = 0.2 

Comments

Popular posts from this blog

scala - 'wrong top statement declaration' when using slick in IntelliJ -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

PySide and Qt Properties: Connecting signals from Python to QML -