一张html页面上有多个单选框,怎样实现选中一个值之后,就立刻在页面上显示选中单选框的那个值?
展开全部
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
<script type="text/javascript">
<!--
function show_selected_item_val($item){
document.getElementById("show_content").innerHTML= $item.value;
}
//-->
</script>
</HEAD>
<BODY>
<form method="post" action="#">
<h3>你喜欢吃啥</h3>
<input type="radio" name="radio[]" id="radio_1" value="青菜" onclick="show_selected_item_val(this)" />
青菜
<input type="radio" name="radio[]" id="radio_2" value="萝卜" onclick="show_selected_item_val(this)"/>
萝卜
<input type="radio" name="radio[]" id="radio_3" value="花菜" onclick="show_selected_item_val(this)"/>
花菜
<input type="radio" name="radio[]" id="radio_4" value="小麦" onclick="show_selected_item_val(this)"/>
小麦
<input type="radio" name="radio[]" id="radio_5" value="西红柿" onclick="show_selected_item_val(this)"/>
西红柿
</p>
你选择的是:<span id="show_content"></div>
</form>
</BODY>
</HTML>
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
<script type="text/javascript">
<!--
function show_selected_item_val($item){
document.getElementById("show_content").innerHTML= $item.value;
}
//-->
</script>
</HEAD>
<BODY>
<form method="post" action="#">
<h3>你喜欢吃啥</h3>
<input type="radio" name="radio[]" id="radio_1" value="青菜" onclick="show_selected_item_val(this)" />
青菜
<input type="radio" name="radio[]" id="radio_2" value="萝卜" onclick="show_selected_item_val(this)"/>
萝卜
<input type="radio" name="radio[]" id="radio_3" value="花菜" onclick="show_selected_item_val(this)"/>
花菜
<input type="radio" name="radio[]" id="radio_4" value="小麦" onclick="show_selected_item_val(this)"/>
小麦
<input type="radio" name="radio[]" id="radio_5" value="西红柿" onclick="show_selected_item_val(this)"/>
西红柿
</p>
你选择的是:<span id="show_content"></div>
</form>
</BODY>
</HTML>
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询