dropdownlist改变不已被选中的值
dropdownlist改变不了被选中的值
var date = new Date();
var day = "";
var month = "";
if (date.getDate() < 10) {
day = "0" + date.getDate().toString();
}
else {
day = date.getDate().toString();
}
if (date.getMonth() < 9) {
month = "0" + (date.getMonth() + 1).toString();
}
else {
month = (date.getMonth() + 1).toString();
}
var result = date.getFullYear() + "年" + month + "月" + day + "日";
$(document).ready(function () {
$("#TextBox1").val(result);
})
</script>
</head>
<body>
<form id="form1" runat="server">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="17" valign="top" background="images/mail_leftbg.gif"><img src="images/left-top-right.gif" width="17" height="29" /></td>
<td valign="top" background="images/content-bg.gif"><table width="100%" height="31" border="0" cellpadding="0" cellspacing="0" class="left_topbg" id="table2">
<tr>
<td height="31"><div class="titlebt">车位设置</div></td>
</tr>
</table></td>
<td width="16" valign="top" background="images/mail_rightbg.gif"><img src="images/nav-right-bg.gif" width="16" height="29" /></td>
</tr>
<tr>
<td valign="middle" background="images/mail_leftbg.gif"> </td>
<td valign="top" bgcolor="#F7F8F9">
<table cellpadding="0" cellspacing="0" width="800px">
<tr>
<td height="30px">
时间:
<asp:TextBox ID="TextBox1" runat="server" onfocus="WdatePicker({minDate:'%y-%M-#{%d+1}', dateFmt:'yyyy年MM月dd日'})"
CssClass="Wdate" Height="25px" onclick="aa()" ></asp:TextBox>
</td>
</tr>
<tr>
<td height="30px"> 全 部:<asp:DropDownList ID="dropall" runat="server" Width="100px">
<asp:ListItem> </asp:ListItem>
<asp:ListItem>3</asp:ListItem>
<asp:ListItem>4</asp:ListItem>
<asp:ListItem>5</asp:ListItem>
<asp:ListItem>6</asp:ListItem>
</asp:DropDownList></td></tr>
<tr>
<td height="30px"> 09:00:<asp:DropDownList ID="dropnine" runat="server" Width="100px">
<asp:ListItem>3</asp:ListItem>
<asp:ListItem>4</asp:ListItem>
<asp:ListItem>5</asp:ListItem>
<asp:ListItem>6</asp:ListItem>
</asp:DropDownList></td></tr>
<tr>
<td height="30px"> 10:00:<asp:DropDownList ID="dropten" runat="server" Width="100px">
<asp:ListItem> </asp:ListItem>
<asp:ListItem>3</asp:ListItem>
<asp:ListItem>4</asp:ListItem>
<asp:ListItem>5</asp:ListItem>
<asp:ListItem>6</asp:ListItem>
</asp:DropDownList></td></tr>
<tr>
<td height="30px"> 11:00:<asp:DropDownList ID="dropele" runat="server" Width="100px">
<asp:ListItem> </asp:ListItem>
<asp:ListItem>3</asp:ListItem>
<asp:ListItem>4</asp:ListItem>
<asp:ListItem>5</asp:ListItem>
<asp:ListItem>6</asp:ListItem>
</asp:DropDownList></td></tr>
<tr>
<td height="30px"> 12:00:<asp:DropDownList ID="droptw" runat="server" Width="100px">
<asp:ListItem> </asp:ListItem>
<asp:ListItem>3</asp:ListItem>
</asp:DropDownList></td></tr>
<tr>
<td height="30px"> 13:00:<asp:DropDownList ID="tropthir" runat="server" Width="100px">
<asp:ListItem> </asp:ListItem>
<asp:ListItem>3</asp:ListItem>
</asp:DropDownList></td></tr>
<tr>
<td height="30px"> 14:00:<asp:DropDownList ID="dropfour" runat="server" Width="100px">
<asp:ListItem> </asp:ListItem>
<asp:ListItem>3</asp:ListItem>
</asp:DropDownList></td></tr>
<tr>
<td height="30px"> 15:00:<asp:DropDownList ID="dropfive" runat="server" Width="100px">
<asp:ListItem> </asp:ListItem>
<asp:ListItem>3</asp:ListItem>
</asp:DropDownList></td></tr>
<tr>
<td height="30px"> 16:00:<asp:DropDownList ID="dropsix" runat="server" Width="100px">
<asp:ListItem> </asp:ListItem>
<asp:ListItem>3</asp:ListItem>
<asp:ListItem>4</asp:ListItem>
<asp:ListItem>5</asp:ListItem>
<asp:ListItem>6</asp:ListItem>
</asp:DropDownList></td>
</tr>
<tr height="30px">
<td> <asp:Button ID="btnset" runat="server" Text="设置" Width="60px"
onclick="btnset_Click" /></td>
</tr>
if (!IsPostBack)
{
//Init();
Show("");
}
if (Request.Form["rq"] != null)
{
string str = Request.Form["rq"].ToString();
show2(Request.Form["rq"].ToString());
}
public void show2(string day)
{
string[] str = new string[] { "09:00", "11:00", "12:00", "13:00", "14:00", "15:00", "16:00" };
for (int i = 0; i < str.Length; i++)
{
string sql1 = "select position from cwsz where day='" + day + "' and sjd='" + str[i] + "'";
var dt1 = db.ExecuteQuery(sql1);
if (dt1.Rows.Count > 0)
{
if (dt1.Rows[0]["position"] != null)
{
if (str[i] == "09:00")
{
if (dt1.Rows[0]["position"].ToString() == "3")
dropnine.SelectedIndex = 1;
else if (dt1.Rows[0]["position"].ToString() == "4")
dropnine.SelectedIndex = 2;
else if (dt1.Rows[0]["position"].ToString() == "5")
dropnine.SelectedIndex = 3;
else
dropnine.SelectedIndex = 4;
}
if (str[i] == "10:00")
{
if (dt1.Rows[0]["position"].ToString() == "3")
dropten.SelectedIndex = 1;
else if (dt1.Rows[0]["position"].ToString() == "4")
dropten.SelectedIndex = 2;
else if (dt1.Rows[0]["position"].ToString() == "5")
dropten.SelectedIndex = 3;
else
dropten.SelectedIndex = 4;
}
if (str[i] == "11:00")
{
if (dt1.Rows[0]["position"].ToString() == "3")
dropele.SelectedIndex = 1;
else if (dt1.Rows[0]["position"].ToString() == "4")
dropele.SelectedIndex = 2;
else if (dt1.Rows[0]["position"].ToString() == "5")
dropele.SelectedIndex = 3;
else
dropele.SelectedIndex = 4;
}
if (str[i] == "12:00")
{
if (dt1.Rows[0]["position"].ToString() == "3")
droptw.SelectedIndex = 1;
else if (dt1.Rows[0]["position"].ToString() == "4")
droptw.SelectedIndex = 2;
else if (dt1.Rows[0]["position"].ToString() == "5")
droptw.SelectedIndex = 3;
else
droptw.SelectedIndex = 4;
}
if (str[i] == "13:00")
{
if (dt1.Rows[0]["position"].ToString() == "3")
tropthir.SelectedIndex = 1;
else if (dt1.Rows[0]["position"].ToString() == "4")
tropthir.SelectedIndex = 2;
else if (dt1.Rows[0]["position"].ToString() == "5")
tropthir.SelectedIndex = 3;
else
tropthir.SelectedIndex = 4;
}
if (str[i] == "14:00")
{
if (dt1.Rows[0]["position"].ToString() == "3")
dropfour.SelectedIndex = 1;
else if (dt1.Rows[0]["position"].ToString() == "4")
dropfour.SelectedIndex = 2;
else if (dt1.Rows[0]["position"].ToString() == "5")
dropfour.SelectedIndex = 3;
else
dropfour.SelectedIndex = 4;
}
求各位帮忙看看 我为什么点击textbox1之后,下拉框大的值不会改变?
------解决思路----------------------
你的代码帖得很多,又是直接帖为文本,别人很难看得清。
下面是教你怎样在论坛帖代码:

var date = new Date();
var day = "";
var month = "";
if (date.getDate() < 10) {
day = "0" + date.getDate().toString();
}
else {
day = date.getDate().toString();
}
if (date.getMonth() < 9) {
month = "0" + (date.getMonth() + 1).toString();
}
else {
month = (date.getMonth() + 1).toString();
}
var result = date.getFullYear() + "年" + month + "月" + day + "日";
$(document).ready(function () {
$("#TextBox1").val(result);
})
</script>
</head>
<body>
<form id="form1" runat="server">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="17" valign="top" background="images/mail_leftbg.gif"><img src="images/left-top-right.gif" width="17" height="29" /></td>
<td valign="top" background="images/content-bg.gif"><table width="100%" height="31" border="0" cellpadding="0" cellspacing="0" class="left_topbg" id="table2">
<tr>
<td height="31"><div class="titlebt">车位设置</div></td>
</tr>
</table></td>
<td width="16" valign="top" background="images/mail_rightbg.gif"><img src="images/nav-right-bg.gif" width="16" height="29" /></td>
</tr>
<tr>
<td valign="middle" background="images/mail_leftbg.gif"> </td>
<td valign="top" bgcolor="#F7F8F9">
<table cellpadding="0" cellspacing="0" width="800px">
<tr>
<td height="30px">
时间:
<asp:TextBox ID="TextBox1" runat="server" onfocus="WdatePicker({minDate:'%y-%M-#{%d+1}', dateFmt:'yyyy年MM月dd日'})"
CssClass="Wdate" Height="25px" onclick="aa()" ></asp:TextBox>
</td>
</tr>
<tr>
<td height="30px"> 全 部:<asp:DropDownList ID="dropall" runat="server" Width="100px">
<asp:ListItem> </asp:ListItem>
<asp:ListItem>3</asp:ListItem>
<asp:ListItem>4</asp:ListItem>
<asp:ListItem>5</asp:ListItem>
<asp:ListItem>6</asp:ListItem>
</asp:DropDownList></td></tr>
<tr>
<td height="30px"> 09:00:<asp:DropDownList ID="dropnine" runat="server" Width="100px">
<asp:ListItem>3</asp:ListItem>
<asp:ListItem>4</asp:ListItem>
<asp:ListItem>5</asp:ListItem>
<asp:ListItem>6</asp:ListItem>
</asp:DropDownList></td></tr>
<tr>
<td height="30px"> 10:00:<asp:DropDownList ID="dropten" runat="server" Width="100px">
<asp:ListItem> </asp:ListItem>
<asp:ListItem>3</asp:ListItem>
<asp:ListItem>4</asp:ListItem>
<asp:ListItem>5</asp:ListItem>
<asp:ListItem>6</asp:ListItem>
</asp:DropDownList></td></tr>
<tr>
<td height="30px"> 11:00:<asp:DropDownList ID="dropele" runat="server" Width="100px">
<asp:ListItem> </asp:ListItem>
<asp:ListItem>3</asp:ListItem>
<asp:ListItem>4</asp:ListItem>
<asp:ListItem>5</asp:ListItem>
<asp:ListItem>6</asp:ListItem>
</asp:DropDownList></td></tr>
<tr>
<td height="30px"> 12:00:<asp:DropDownList ID="droptw" runat="server" Width="100px">
<asp:ListItem> </asp:ListItem>
<asp:ListItem>3</asp:ListItem>
</asp:DropDownList></td></tr>
<tr>
<td height="30px"> 13:00:<asp:DropDownList ID="tropthir" runat="server" Width="100px">
<asp:ListItem> </asp:ListItem>
<asp:ListItem>3</asp:ListItem>
</asp:DropDownList></td></tr>
<tr>
<td height="30px"> 14:00:<asp:DropDownList ID="dropfour" runat="server" Width="100px">
<asp:ListItem> </asp:ListItem>
<asp:ListItem>3</asp:ListItem>
</asp:DropDownList></td></tr>
<tr>
<td height="30px"> 15:00:<asp:DropDownList ID="dropfive" runat="server" Width="100px">
<asp:ListItem> </asp:ListItem>
<asp:ListItem>3</asp:ListItem>
</asp:DropDownList></td></tr>
<tr>
<td height="30px"> 16:00:<asp:DropDownList ID="dropsix" runat="server" Width="100px">
<asp:ListItem> </asp:ListItem>
<asp:ListItem>3</asp:ListItem>
<asp:ListItem>4</asp:ListItem>
<asp:ListItem>5</asp:ListItem>
<asp:ListItem>6</asp:ListItem>
</asp:DropDownList></td>
</tr>
<tr height="30px">
<td> <asp:Button ID="btnset" runat="server" Text="设置" Width="60px"
onclick="btnset_Click" /></td>
</tr>
if (!IsPostBack)
{
//Init();
Show("");
}
if (Request.Form["rq"] != null)
{
string str = Request.Form["rq"].ToString();
show2(Request.Form["rq"].ToString());
}
public void show2(string day)
{
string[] str = new string[] { "09:00", "11:00", "12:00", "13:00", "14:00", "15:00", "16:00" };
for (int i = 0; i < str.Length; i++)
{
string sql1 = "select position from cwsz where day='" + day + "' and sjd='" + str[i] + "'";
var dt1 = db.ExecuteQuery(sql1);
if (dt1.Rows.Count > 0)
{
if (dt1.Rows[0]["position"] != null)
{
if (str[i] == "09:00")
{
if (dt1.Rows[0]["position"].ToString() == "3")
dropnine.SelectedIndex = 1;
else if (dt1.Rows[0]["position"].ToString() == "4")
dropnine.SelectedIndex = 2;
else if (dt1.Rows[0]["position"].ToString() == "5")
dropnine.SelectedIndex = 3;
else
dropnine.SelectedIndex = 4;
}
if (str[i] == "10:00")
{
if (dt1.Rows[0]["position"].ToString() == "3")
dropten.SelectedIndex = 1;
else if (dt1.Rows[0]["position"].ToString() == "4")
dropten.SelectedIndex = 2;
else if (dt1.Rows[0]["position"].ToString() == "5")
dropten.SelectedIndex = 3;
else
dropten.SelectedIndex = 4;
}
if (str[i] == "11:00")
{
if (dt1.Rows[0]["position"].ToString() == "3")
dropele.SelectedIndex = 1;
else if (dt1.Rows[0]["position"].ToString() == "4")
dropele.SelectedIndex = 2;
else if (dt1.Rows[0]["position"].ToString() == "5")
dropele.SelectedIndex = 3;
else
dropele.SelectedIndex = 4;
}
if (str[i] == "12:00")
{
if (dt1.Rows[0]["position"].ToString() == "3")
droptw.SelectedIndex = 1;
else if (dt1.Rows[0]["position"].ToString() == "4")
droptw.SelectedIndex = 2;
else if (dt1.Rows[0]["position"].ToString() == "5")
droptw.SelectedIndex = 3;
else
droptw.SelectedIndex = 4;
}
if (str[i] == "13:00")
{
if (dt1.Rows[0]["position"].ToString() == "3")
tropthir.SelectedIndex = 1;
else if (dt1.Rows[0]["position"].ToString() == "4")
tropthir.SelectedIndex = 2;
else if (dt1.Rows[0]["position"].ToString() == "5")
tropthir.SelectedIndex = 3;
else
tropthir.SelectedIndex = 4;
}
if (str[i] == "14:00")
{
if (dt1.Rows[0]["position"].ToString() == "3")
dropfour.SelectedIndex = 1;
else if (dt1.Rows[0]["position"].ToString() == "4")
dropfour.SelectedIndex = 2;
else if (dt1.Rows[0]["position"].ToString() == "5")
dropfour.SelectedIndex = 3;
else
dropfour.SelectedIndex = 4;
}
求各位帮忙看看 我为什么点击textbox1之后,下拉框大的值不会改变?
------解决思路----------------------
你的代码帖得很多,又是直接帖为文本,别人很难看得清。
下面是教你怎样在论坛帖代码: