【发布时间】:2015-01-09 21:45:54
【问题描述】:
我有一组单选按钮:
<input type="radio" name="product" value="Apple"/>
<input type="radio" name="product" value="Orange"/>
<input type="radio" name="product" value="Grape"/>
下面的两个按钮将用户带到不同的位置
<button type="button" id="ButtonHERE">CLICK TO GO HERE</button>
<button type="button" id="ButtonTHERE">CLICK TO GO THERE</button>
我想在 ButtonTHERE 上放置一个 onclick 函数,以便在单击它时触发 window.location.href 函数并转到 "shoppingcart.html?value" 其中 value 是所选单选按钮的值。
我可以在按钮的onclick 内执行此操作 ALL,还是应该在单击单选按钮时创建一个外部函数,它会设置一个变量,然后将该变量加载到"shoppingcart.html?value"?
【问题讨论】:
标签: javascript html forms function radio-button