网页里有一个下拉列表和一个OK按钮,要求点击后下拉列表变成单选按钮。( 下拉列表的值给了单选按钮 )代码如下 :
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script src="Scripts/jquery-1.4.1.js" type="text/javascript"></script>
<script type="text/javascript">
function btnOKClientClick() {
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:DropDownList ID="DropDownList1" runat="server" Height="23px" Width="100px">
<asp:ListItem >北京</asp:ListItem>
<asp:ListItem >上海</asp:ListItem>
<asp:ListItem >广州</asp:ListItem>
</asp:DropDownList>
<asp:Button ID="btnOk" runat="server" Height="19px" Text="OK" Width="48px" OnClientClick="btnOKClientClick()"/>
<asp:RadioButton ID="RadioButton1" runat="server" />
</div>
</form>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script src="Scripts/jquery-1.4.1.js" type="text/javascript"></script>
<script type="text/javascript">
function btnOKClientClick() {
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:DropDownList ID="DropDownList1" runat="server" Height="23px" Width="100px">
<asp:ListItem >北京</asp:ListItem>
<asp:ListItem >上海</asp:ListItem>
<asp:ListItem >广州</asp:ListItem>
</asp:DropDownList>
<asp:Button ID="btnOk" runat="server" Height="19px" Text="OK" Width="48px" OnClientClick="btnOKClientClick()"/>
<asp:RadioButton ID="RadioButton1" runat="server" />
</div>
</form>
</body>
</html>
解决方案 »
- 谁能给说说Ext中panel和viewPort的区别?
- jQuery+ajax如何实现动态多个form的无刷新文件上传
- 有意思。。看看你能否把图片全放在网页正中间?
- 感觉有点简单的问题
- 求助,JavaScript定时器的问题,在线等;帮我看看是哪里错了?
- innerHTML一个js,怎样才能加载它?
- my97datepicker的问题
- 一个页面里有两个iframe,怎么样把其中一个iframe 中<html></html>之间的内容“赋值”给另外一个iframe?!
- 新年到,明天放假,恭贺新年!散点分 ^_^
- 关于在jsp中标题的背景
- 【急切】汉字字符串作为javascript函数的参数,为什么没有反应呢?(与php的混合应用)
- js文件中怎么连接mysql数据库??
function btnOKClientClick() {
var selectValue = document.getElementById("DropDownList1").value;
document.getElementById("RadioButton1").value = selectValue;
}
<head id="Head1" runat="server">
<title></title> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript">
function btnOKClientClick() {
var rdo = "";
$("#DropDownList1 option").each(function(){
rdo+= "<input type='radio' value='"+$(this).val()+"' name='city' />"+$(this).text();
});
$("#btnOk").after(rdo);
return false;
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:DropDownList ID="DropDownList1" runat="server" Height="23px" Width="100px">
<asp:ListItem Value="bj" >北京</asp:ListItem>
<asp:ListItem Value="sh" >上海</asp:ListItem>
<asp:ListItem Value="gz" >广州</asp:ListItem>
</asp:DropDownList>
<asp:Button ID="btnOk" runat="server" Height="19px" Text="OK" Width="48px" OnClientClick="return btnOKClientClick()"/>
</div>
</form>
</body>
</html>是不是要这样 。
有两个疑问:1.能否把 DropDownList 隐藏,只显示radio
2.$("#btnOk").after(rdo); 这段的能否给点解释,after起到什么作用。
2.是在button后面添加一个radiobutton元素'rdo'
$("#btnOk").after(rdo); 在#btnOk(就是那个按钮) 后面添加元素 。 rdo是拼的字符串 。