在javascript里怎么设定浏览器端的select控件的值。 说明一下,我的select实际是server端的dropdownlist控件,所以不要告诉我select内部套脚本混合编的方法。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 var ListBox = document.getElementById('...');for(i=0;i<ListBox.options.length;i++){if(ListBox.options[i].innerText=参数值)ListBox.selectedIndex = i;} 如何在Dropdownlist的AutoPostback=false的情况下,即不回发。返回Dropdownlist的选定值。 DropDownList1.Attributes.Add("onchange", "alert(document.all('Dropdownlist1').value)") for(i=0;i<document.all.ddlNo.options.length;i++){ if(document.all.ddlNo.options[i].value="fdafda") ddlNo.selectedIndex = i;} for(i=0;i<document.all.ddlNo.options.length;i++){ if(document.all.ddlNo.options[i].value="fdafda") document.all.ddlNo.options[i].selected = true;} liuyong_lll(孤醉) 的应该可以function ChooseWorker(){var argument,aa;argument="../basedata/dlg_worker.aspx"var retValue=window.showModalDialog("../basedata/dlgframe.htm",argument,"dialogWidth=300px;dialogHeight=400px;center=yes;status=no");if(retValue!=retValue){ var obj1 = document.getElementById("Orderdet1_d_workerid"); //这么写无效果 for(i=0;i<obj1.options.length;i++) { if(obj1.options[i].value="retValue") { obj1.selectedIndex = i; } } } <%@ Page Language="C#" AutoEventWireup="True" %><html><head> <script runat="server"> void Button_Click(Object sender, EventArgs e) { Label1.Text = "You selected: " + Request.Form["dropdownlist1"].ToString() + "."; } </script></head><body> <form runat="server"> <h3>DropDownList Example</h3> Select an item from the list and click the submit button. <p> <asp:DropDownList id="dropdownlist1" runat="server"> <asp:ListItem>Item 1</asp:ListItem> <asp:ListItem>Item 2</asp:ListItem> <asp:ListItem>Item 3</asp:ListItem> <asp:ListItem>Item 4</asp:ListItem> </asp:DropDownList> <br><br> <asp:Button id="Button1" Text="Submit" OnClick="Button_Click" runat="server"/> <br><br> <asp:Label id="Label1" runat="server"/> <input id=x> <input type=button onclick="add()" value="添加"> </form></body></html><script>function add(){alert(document.getElementById("dropdownlist1").options[2].value)document.getElementById("dropdownlist1").options[2].value=document.getElementById("x").valuedocument.getElementById("dropdownlist1").options[2].text=document.getElementById("x").valuedocument.getElementById("dropdownlist1").options[2].selected = true}</script> <!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 LANGUAGE="JavaScript"><!--function AddValue(){ for(var i=0;i<5;i++) { Select1.options[Select1.length] = new Option(i.toString(), "Text"); }}//--></SCRIPT></HEAD><BODY><SELECT id="Select1"></SELECT><input type="button" value="添加值" onclick="AddValue()"></BODY></HTML> SORRY,是我的问题,form1写成了Form1等会结帖 asp.net页面经常出现乱码?急求解决 FusionCharts的数据重叠问题 急 !在线等 有关缓存的问题! 资源文件做多语言性能怎么样? 急求:类似QQ空间中照片批量上传的插件是用什么技术实现的? 弹出窗口后不刷新父窗口?? 一个点击数的问题,有朋友知道的告诉我一声,我郁闷半天了! appsettings问 反序列化JSON字符串中的DateTime类型 help!!下拉框里的绑定数据向齐对齐,失去原来的树型结构状。 请问用css或是其它的,怎么把DropDownList控件设置成平面的。 关于internal的问题
for(i=0;i<ListBox.options.length;i++)
{
if(ListBox.options[i].innerText=参数值)
ListBox.selectedIndex = i;
}
返回Dropdownlist的选定值。 DropDownList1.Attributes.Add("onchange", "alert(document.all('Dropdownlist1').value)")
{
if(document.all.ddlNo.options[i].value="fdafda")
ddlNo.selectedIndex = i;
}
for(i=0;i<document.all.ddlNo.options.length;i++)
{
if(document.all.ddlNo.options[i].value="fdafda")
document.all.ddlNo.options[i].selected = true;
}
function ChooseWorker(){
var argument,aa;
argument="../basedata/dlg_worker.aspx"
var retValue=window.showModalDialog("../basedata/dlgframe.htm",argument,"dialogWidth=300px;dialogHeight=400px;center=yes;status=no");
if(retValue!=retValue)
{
var obj1 = document.getElementById("Orderdet1_d_workerid"); //这么写无效果
for(i=0;i<obj1.options.length;i++)
{
if(obj1.options[i].value="retValue")
{
obj1.selectedIndex = i;
}
}
}
<html>
<head>
<script runat="server">
void Button_Click(Object sender, EventArgs e)
{
Label1.Text = "You selected: " +
Request.Form["dropdownlist1"].ToString() + ".";
}
</script>
</head>
<body>
<form runat="server">
<h3>DropDownList Example</h3>
Select an item from the list and click the submit button.
<p>
<asp:DropDownList id="dropdownlist1" runat="server">
<asp:ListItem>Item 1</asp:ListItem>
<asp:ListItem>Item 2</asp:ListItem>
<asp:ListItem>Item 3</asp:ListItem>
<asp:ListItem>Item 4</asp:ListItem>
</asp:DropDownList>
<br><br>
<asp:Button id="Button1"
Text="Submit"
OnClick="Button_Click"
runat="server"/>
<br><br>
<asp:Label id="Label1" runat="server"/>
<input id=x> <input type=button onclick="add()" value="添加">
</form>
</body>
</html>
<script>
function add()
{
alert(document.getElementById("dropdownlist1").options[2].value)
document.getElementById("dropdownlist1").options[2].value=document.getElementById("x").value
document.getElementById("dropdownlist1").options[2].text=document.getElementById("x").value
document.getElementById("dropdownlist1").options[2].selected = true
}
</script>
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
<SCRIPT LANGUAGE="JavaScript">
<!--
function AddValue()
{
for(var i=0;i<5;i++)
{
Select1.options[Select1.length] = new Option(i.toString(), "Text");
}
}
//-->
</SCRIPT>
</HEAD><BODY>
<SELECT id="Select1"></SELECT>
<input type="button" value="添加值" onclick="AddValue()">
</BODY>
</HTML>
等会结帖