如何动态地显示单选框中选择的值
<td><label><input class="evaluation-radio" style="float:left; margin-right:10px" type="radio" data-form="uniform" name="source1" value="10">10</label></td>
<td><label><input class="evaluation-radio" style="float:left; margin-right:10px" type="radio" data-form="uniform" name="source1" value="8">8</label></td>
<td><label><input class="evaluation-radio" style="float:left; margin-right:10px" type="radio" data-form="uniform" name="source1" value="6">6</label></td>
<td><label><input class="evaluation-radio" style="float:left; margin-right:10px" type="radio" data-form="uniform" name="source1" value="4">4</label></td>
<td><label><input class="evaluation-radio" style="float:left; margin-right:10px" type="radio" data-form="uniform" name="source1" value="2">2</label></td>
<td class="inRight">
分</td>
想要在红色的“分”字处动态地显示出上面的单选框中所选择的结果的value值
------解决方案--------------------JS
给上面的每个选项添加一个触发事件,传参数为自己本身的值,触发后调用JS
JS里面先获取
传来的参数值,
获取节点document.getElementById("showmsg");
然后直接显示就行了
document.getElementById("showmsg").interHtml="value";
至于显示
改成
<td class="inRight"><span id="showmsg">分</span></td>
------解决方案--------------------<script type="text/javascript">
function getSource(e){
document.getElementById("showmsg").innerText=e;
}
</script>
<td><label><input class="evaluation-radio" style="float:left; margin-right:10px" type="radio" onclick="getSource
(this.value)" data-form="uniform" name="source1" value="10">10</label></td>
<td><label><input class="evaluation-radio" style="float:left; margin-right:10px" type="radio" onclick="getSource
(this.value)" data-form="uniform" name="source1" value="8">8</label></td>
<td><label><input class="evaluation-radio" style="float:left; margin-right:10px" type="radio" onclick="getSource