如何根据引导项选择设置变量
How to set a variable based on bootstrap item selection
所以我试图根据用户选择的LED模块设置变量w(为瓦数)。我正在使用bootstrap库。
正文标签的内容如下:
<div class="container">
<h2>LED Power Supply Calculator</h2>
<p>Please select your LED type, then type how many LEDs you will be using in your box</p>
<div class="dropdown">
<button class="btn btn-default dropdown-toggle" type="button" id="menu1" data-toggle="dropdown">Select your LED
<span class="caret"></span></button>
<ul class="dropdown-menu" role="menu" aria-labelledby="menu1">
<li class="dropdown-header">Wide angle beam</li>
<li role="presentation"><a role="menuitem" tabindex="-1" href="javascript: onclick(w = 1.2);">HLC3S - HW W65K</a></li>
<li role="presentation"><a role="menuitem" tabindex="-1" href="javascript: onclick(w = 0.72);">HLC3S - LW W65K</a></li>
<li role="presentation" class="divider"></li>
<li class="dropdown-header">Standard beam</li>
<li role="presentation"><a role="menuitem" tabindex="-1" href="javascript: onclick(w = 0.06);">HLC3S XD W65K</a></li>
</ul>
</div>
<BR>
<form role="form">
<div class="form-group">
<label for="usr">How many LEDs</label>
<input type="number" class="form-control" id="usr">
</div>
</div>
<script type="text/javascript">
document.write(w * 10);
</script>
我想最终将瓦数乘以用户放入的led的数量。现在,当用户点击LED类型时,我只需要帮助设置变量'w'。
如果你做一个文档。写你的所有内容将被删除,而不是在这里我们定义了一个函数w()
,它接受瓦特的值,并进行计算,并将其打印在html <span class="form-control" id="watt">
希望有帮助
<div class="container">
<h2>LED Power Supply Calculator</h2>
<p>Please select your LED type, then type how many LEDs you will be using in your box</p>
<div class="dropdown">
<button class="btn btn-default dropdown-toggle" type="button" id="menu1" data-toggle="dropdown">Select your LED
<span class="caret"></span></button>
<ul class="dropdown-menu" role="menu" aria-labelledby="menu1">
<li class="dropdown-header">Wide angle beam</li>
<li role="presentation"><a role="menuitem" tabindex="-1" onclick="w(1.2);">HLC3S - HW W65K</a></li>
<li role="presentation"><a role="menuitem" tabindex="-1" onclick="w(0.72);">HLC3S - LW W65K</a></li>
<li role="presentation" class="divider"></li>
<li class="dropdown-header">Standard beam</li>
<li role="presentation"><a role="menuitem" tabindex="-1" onclick="w(0.06);">HLC3S XD W65K</a></li>
</ul>
</div>
<BR>
<form role="form">
<div class="form-group">
<label for="usr">How many LEDs</label>
<input type="number" class="form-control" id="usr">
<span class="form-control" id="watt"></span>
</div>
</div>
<script type="text/javascript">
function w(val){
document.getElementById('watt').innerHTML = val*10;
}
//document.write(w * 10);
</script>
相关文章:
- 如何根据另一选择中的选择设置一个选择中的文本
- jQuery为按钮选择设置活动类
- 根据两个下拉菜单的选择设置隐藏值
- Bootstrap/AngularJs:如何为导航类的活动选择设置粗体属性
- Ember选择设置内容绑定
- KnockoutJS可观测值为't通过选择设置
- 3 选项从数据库中删除更改时选择设置值
- 如何根据下拉框选择设置文本框值
- 挖空 + 选择2 -- 设置默认值
- jQuery 验证 - 根据用户选择设置条件规则
- 使用角度引导选择设置下拉列表的选定选项
- 运行流星如何选择设置文件
- Dojo选择设置值不能与动态生成的选项一起工作
- 如何根据引导项选择设置变量
- 多重选择设置导致angular出错
- 具体化选择设置动态选项问题
- 表单:选择设置img src
- 基于列表框选择设置列表项
- 根据先前选择标记中的选择设置选择标记的可见性
- 如何根据下拉选择设置单选按钮值