不错呦!smile@林凯西,确保“准备文件”中的几个文件都有安装,S...您好,看了您这篇帖子觉得很有帮助。但是有个问题想请...我的修改过了怎么还被恶意注册呢 @jjjjiiii 用PJ快9年了,主要是A...PJ3啊,貌似很少有人用PJ了,现在不是WP就是z...@332347365,我当时接入时错误码没有-10...楼主,ChkValue值应为-103是什么意思呢?...大哥 你最近能看到我发的信息,请跟我联系,我有个制...
修改资料时设定下拉菜单某个值为选中状态
编辑:dnawo 日期:2007-10-11
在修改资料时,为方便用户操作,必须将先前选取的下拉菜单的某个值设定为选中状态,通常我们用ASP书写如下代码:
碰上下拉菜单项非常多时,书写起来非常浪费时间,下边写了个JS函数用来实现转换,只需将原来的<select>复制粘贴到页面begin和end之间,点击转换按钮,页面即显示转换后的<select>,再复制粘贴回去即可:
[Ctrl+A 全部选择 提示:你可先修改部分代码,再按运行]
想看看动网是怎么解决这个问题的,打开mymodify.asp找了他的转换函数:
其中第一个参数为要选定的值,第二个参数为全部<select>项的值组成的字符串,各项值以逗号隔开,如:Chk_select("2222","1111,2222,3333,4444")。
复制内容到剪贴板 程序代码
<select name="select">
<option value="1111" <% If ors("field")="1111" Then Response.Write("selected") %>>111</option>
<option value="2222" <% If ors("field")="2222" Then Response.Write("selected") %>>222</option>
<option value="333" <% If ors("field")="333" Then Response.Write("selected") %>>333</option>
<option value="444" <% If ors("field")="444" Then Response.Write("selected") %>>444</option>
</select>
<option value="1111" <% If ors("field")="1111" Then Response.Write("selected") %>>111</option>
<option value="2222" <% If ors("field")="2222" Then Response.Write("selected") %>>222</option>
<option value="333" <% If ors("field")="333" Then Response.Write("selected") %>>333</option>
<option value="444" <% If ors("field")="444" Then Response.Write("selected") %>>444</option>
</select>
碰上下拉菜单项非常多时,书写起来非常浪费时间,下边写了个JS函数用来实现转换,只需将原来的<select>复制粘贴到页面begin和end之间,点击转换按钮,页面即显示转换后的<select>,再复制粘贴回去即可:
HTML代码
[Ctrl+A 全部选择 提示:你可先修改部分代码,再按运行]
想看看动网是怎么解决这个问题的,打开mymodify.asp找了他的转换函数:
复制内容到剪贴板 程序代码
<%
Function Chk_select(str1,str2)
Dim k
str2=Split(str2,",")
If IsEmpty(str1) or str1="" Then chk_select="<option value='' selected>...</option>"
For k=0 to ubound(str2)
chk_select=chk_select+"<option value="+str2(k)
If str2(k)=str1 Then chk_select=chk_select+" selected "
chk_select=chk_select+" >"+str2(k)+"</option>"
Next
End Function
%>
Function Chk_select(str1,str2)
Dim k
str2=Split(str2,",")
If IsEmpty(str1) or str1="" Then chk_select="<option value='' selected>...</option>"
For k=0 to ubound(str2)
chk_select=chk_select+"<option value="+str2(k)
If str2(k)=str1 Then chk_select=chk_select+" selected "
chk_select=chk_select+" >"+str2(k)+"</option>"
Next
End Function
%>
其中第一个参数为要选定的值,第二个参数为全部<select>项的值组成的字符串,各项值以逗号隔开,如:Chk_select("2222","1111,2222,3333,4444")。
评论: 0 | 引用: 0 | 查看次数: 4892
发表评论
请登录后再发表评论!