如何修改下面ASP代码中下拉菜单中的年份的属性?
<TDwidth="20%"align=right>购买/服务(日期)</TD><TDwidth="80%"><selectid=gmrq1name=gmrq1><%Re...
<TD width="20%" align=right>
购买/服务(日期)
</TD>
<TD width="80%">
<select id=gmrq1 name=gmrq1>
<%
Response.Write ("<option value=2005>2005</option>")
Dim year_s,year_e,year_n
year_s=1990
year_e=2010
For year_n=year_s To year_e
Response.Write ("<option value='"&year_n&"'>"&year_n&"</option>")
Next
%>
</select>
年
<select id=gmrq2 name=gmrq2>
<%
Dim m_s,m_e,m_n
m_s=1
m_e=12
For m_n=m_s To m_e
Response.Write ("<option value='"&m_n&"'>"&m_n&"</option>")
Next
%>
</select>
月
<select id=gmrq3 name=gmrq3>
<%Dim d_s,d_e,d_n
d_s=1
d_e=31
For d_n=d_s To d_e
Response.Write ("<option value='"&d_n&"'>"&d_n&"</option>")
Next
%>
</select>
日<font color="#FF1493">**</font>
</TD>
以上便是要修改的代码。这个是我下载模版下来的,他默认显示的时间是2005年1月1日,下拉菜单中可以选择的最大年份是2010年。我需要改成默认显示的时间是系统的时间,下拉菜单中可以选择的年份比系统时间大10年左右(最低不能少于系统的年份)。
选择了年月日是写入数据库中gmrq这个表格中的,如代码中
年<select id=gmrq1 name=gmrq1>
……
月<select id=gmrq2 name=gmrq2>
……
日<select id=gmrq3 name=gmrq3>
不能删除或是忽略这个。 展开
购买/服务(日期)
</TD>
<TD width="80%">
<select id=gmrq1 name=gmrq1>
<%
Response.Write ("<option value=2005>2005</option>")
Dim year_s,year_e,year_n
year_s=1990
year_e=2010
For year_n=year_s To year_e
Response.Write ("<option value='"&year_n&"'>"&year_n&"</option>")
Next
%>
</select>
年
<select id=gmrq2 name=gmrq2>
<%
Dim m_s,m_e,m_n
m_s=1
m_e=12
For m_n=m_s To m_e
Response.Write ("<option value='"&m_n&"'>"&m_n&"</option>")
Next
%>
</select>
月
<select id=gmrq3 name=gmrq3>
<%Dim d_s,d_e,d_n
d_s=1
d_e=31
For d_n=d_s To d_e
Response.Write ("<option value='"&d_n&"'>"&d_n&"</option>")
Next
%>
</select>
日<font color="#FF1493">**</font>
</TD>
以上便是要修改的代码。这个是我下载模版下来的,他默认显示的时间是2005年1月1日,下拉菜单中可以选择的最大年份是2010年。我需要改成默认显示的时间是系统的时间,下拉菜单中可以选择的年份比系统时间大10年左右(最低不能少于系统的年份)。
选择了年月日是写入数据库中gmrq这个表格中的,如代码中
年<select id=gmrq1 name=gmrq1>
……
月<select id=gmrq2 name=gmrq2>
……
日<select id=gmrq3 name=gmrq3>
不能删除或是忽略这个。 展开
3个回答
展开全部
year_s= Year(now()) 获取年份, ASP输出:<%=Year(now())%>
year_e=DateAdd(interval, 10, year_s)
<%
Response.Write " <select size=""1"" name=""datYear"">"
For i = DateAdd(interval, 10, Year(Date)) To Year(Date)
Response.Write "<option value=""" & i & """"
If i = Year(Date) Then
Response.Write " selected"
End If
Response.Write ">" & i & "</option>"
Next
Response.Write " </select> - "
Response.Write " <select size=""1"" name=""datMonth"">"
For i = 1 To 12
Response.Write "<option value=""" & i & """"
If i = Month(Date) Then
Response.Write " selected"
End If
Response.Write ">" & i & "</option>"
Next
Response.Write " </select> - "
Response.Write " <select size=""1"" name=""datDay"">"
For i = 1 To 31
Response.Write "<option value=""" & i & """"
If i = Day(Date) Then
Response.Write " selected"
End If
Response.Write ">" & i & "</option>"
Next
Response.Write " </select> "
%>
year_e=DateAdd(interval, 10, year_s)
<%
Response.Write " <select size=""1"" name=""datYear"">"
For i = DateAdd(interval, 10, Year(Date)) To Year(Date)
Response.Write "<option value=""" & i & """"
If i = Year(Date) Then
Response.Write " selected"
End If
Response.Write ">" & i & "</option>"
Next
Response.Write " </select> - "
Response.Write " <select size=""1"" name=""datMonth"">"
For i = 1 To 12
Response.Write "<option value=""" & i & """"
If i = Month(Date) Then
Response.Write " selected"
End If
Response.Write ">" & i & "</option>"
Next
Response.Write " </select> - "
Response.Write " <select size=""1"" name=""datDay"">"
For i = 1 To 31
Response.Write "<option value=""" & i & """"
If i = Day(Date) Then
Response.Write " selected"
End If
Response.Write ">" & i & "</option>"
Next
Response.Write " </select> "
%>
更多追问追答
追问
是把你这段代码覆盖了我这段吗?
追答
year_s= Year(now()) 获取年份, ASP输出:
year_e=DateAdd(interval, 10, year_s)
你试试这个,我现在没环境实验
展开全部
改为如下:
<TD width="20%" align=right>
购买/服务(日期)
</TD>
<TD width="80%">
<select id=gmrq1 name=gmrq1>
<%
year_now=Year(now())
Response.Write ("<option value='year_now'>"&year_now&"</option>")
Dim year_s,year_e,year_n
year_s=2000
year_e=2020
For year_n=year_s To year_e
Response.Write ("<option value='"&year_n&"'>"&year_n&"</option>")
Next
%>
</select>
年
<select id=gmrq2 name=gmrq2>
<%
month_now=month(now())
Response.Write ("<option value='month_now'>"&month_now&"</option>")
Dim m_s,m_e,m_n
m_s=1
m_e=12
For m_n=m_s To m_e
Response.Write ("<option value='"&m_n&"'>"&m_n&"</option>")
Next
%>
</select>
月
<select id=gmrq3 name=gmrq3>
<%
day_now=day(now())
Response.Write ("<option value='day_now'>"&day_now&"</option>")
Dim d_s,d_e,d_n
d_s=1
d_e=31
For d_n=d_s To d_e
Response.Write ("<option value='"&d_n&"'>"&d_n&"</option>")
Next
%>
</select>
日<font color="#FF1493">**</font>
</TD>
<TD width="20%" align=right>
购买/服务(日期)
</TD>
<TD width="80%">
<select id=gmrq1 name=gmrq1>
<%
year_now=Year(now())
Response.Write ("<option value='year_now'>"&year_now&"</option>")
Dim year_s,year_e,year_n
year_s=2000
year_e=2020
For year_n=year_s To year_e
Response.Write ("<option value='"&year_n&"'>"&year_n&"</option>")
Next
%>
</select>
年
<select id=gmrq2 name=gmrq2>
<%
month_now=month(now())
Response.Write ("<option value='month_now'>"&month_now&"</option>")
Dim m_s,m_e,m_n
m_s=1
m_e=12
For m_n=m_s To m_e
Response.Write ("<option value='"&m_n&"'>"&m_n&"</option>")
Next
%>
</select>
月
<select id=gmrq3 name=gmrq3>
<%
day_now=day(now())
Response.Write ("<option value='day_now'>"&day_now&"</option>")
Dim d_s,d_e,d_n
d_s=1
d_e=31
For d_n=d_s To d_e
Response.Write ("<option value='"&d_n&"'>"&d_n&"</option>")
Next
%>
</select>
日<font color="#FF1493">**</font>
</TD>
追问
提示变量未定义: 'year_now'
追答
<%
dim year_now
year_now=Year(now())
………………
<%
dim month_now
month_now=month(now())
………………
<%
dim day_now
day_now=day(now())
一般不会提示的,如果有提示,可以按照上面方式修改
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
year_s= Year(now()) 获取年份, ASP输出:<%=Year(now())%>
year_e=year_s + 10
year_e=year_s + 10
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询