[英]Width and length price calculator help ( adding options ) using javascript / jquery
Hello Everyone , 大家好 ,
I have a problem with my price calculator when i've tryed to add options 尝试添加选项时,我的价格计算器出现问题
( Js fiddle here = http://jsfiddle.net/wemdragon/hXydV/ ) (Js小提琴在这里= http://jsfiddle.net/wemdragon/hXydV/ )
What i'm trying to do is where it says: 我想做的是它说的地方:
var firstoption=$('select#myselect')
i would like the options value turned into a price value like : option value (Which is 1 ) = 20.00 but can't seem to do it. var firstoption=$('select#myselect')
我希望将选项值转换为价格值,如:选项值(哪个为1)= 20.00,但似乎无法做到。
If anyone could nicely help me and tell me what i'm doing wrong with this, i'l really appreciate it. 如果有人能很好地帮助我,并告诉我我在做错什么,我将非常感激。
You should probably give the <option>
the values you want, then just use: 您可能应该为
<option>
所需的值,然后使用:
var firstOption = +$('select#myselect').val();
jQuery val()
grabs the selected value, and the +
converts the string value (like "20"
) to a numeric. jQuery
val()
获取选定的值,而+
将字符串值(如"20"
)转换为数字。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.