【发布时间】:2021-06-08 20:02:13
【问题描述】:
需要将选定的单选按钮值存储在变量中,我不知道该怎么做
<input type="radio" name="spilldeck" class="happy" id="happy" value="0" checked />
<input type="radio" name="spilldeck" class="neutral" id="neutral" value="1" />
<input type="radio" name="spilldeck" class="sad" id="sad" value="2" />
我想我可以通过添加 onchange 事件来监听点击了哪个单选按钮
<input type="radio" name="spilldeck" class="happy" id="happy" value="0" onChange="getValue(this)" checked />
<input type="radio" name="spilldeck" class="neutral" id="neutral" value="1" onChange="getValue(this)" />
<input type="radio" name="spilldeck" class="sad" id="sad" value="2" onChange="getValue(this)" />
现在我需要将选定的值存储在 $spilldeck = ......
【问题讨论】: