从 SELECT 中获取数据
假设我有这个:
<select name="exposure">
<option value='1,0.005'>Micro</option>
<option value='2,0.007'>Mini</option>
</select>
<select name="clicks">
<option value="2500">2500 - Clicks</option >
<option value="500">500 - Clicks</option >
</select>
<label>Price:</label>
<div id="price"></div>
我该怎么办,所以每当我从 select="exposure"
中选择某些内容时,它会自动更改 select="clicks"
的选项,最后,从 select="clicks" 中获取值,然后将其与 select="exposure"
的第二个值相乘。
示例
我选择了
<option value='2,0.007'>Mini</option>
使用此选项,唯一可用的点击套餐是:
<option value="2500">2500 - Clicks</option >
价格:0.007*2500 = 17,5
这可能吗?
Let's say I have this:
<select name="exposure">
<option value='1,0.005'>Micro</option>
<option value='2,0.007'>Mini</option>
</select>
<select name="clicks">
<option value="2500">2500 - Clicks</option >
<option value="500">500 - Clicks</option >
</select>
<label>Price:</label>
<div id="price"></div>
How can I do, so whenever I select something from select="exposure"
, it will automatically change the OPTIONS of select="clicks"
, and at last, take the value from select="clicks" and then multiply it with the second value of select="exposure"
.
Example
I have selected
<option value='2,0.007'>Mini</option>
And with this option, the only click package that is available is:
<option value="2500">2500 - Clicks</option >
Price: 0.007*2500 = 17,5
Is that possible?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
试试这个
Try this
“选择选择的值”:
仅使某些选项可用:
从值中提取数据:
但我个人建议不要通过属性“值”传递附加信息;更好的解决方案是为此类需求创建一个新属性。
To "select value of select":
To make only some options available:
To extract data from value:
But I personally suggest to not pass additional information via the attribute "value"; better solution would be to create a new attribute to such needs.