社区
ASP
帖子详情
求表单下拉框:既可以手动输入,也可以下拉选择已有数据!
somecom
2003-08-19 10:11:21
各位大侠,求助!
求表单下拉框:既可以手动输入,也可以下拉选择已有数据!
还有,那位大侠有Fontpage里的表单项:列表表单、列表域?我的软件上的两个选项是灰色的,无论怎样添加都出不来!
谢过了!
<select size="1" name="D1">这里的值既可以物动输入,也可以下拉选择已有数据!</select>
...全文
1151
6
打赏
收藏
求表单下拉框:既可以手动输入,也可以下拉选择已有数据!
各位大侠,求助! 求表单下拉框:既可以手动输入,也可以下拉选择已有数据! 还有,那位大侠有Fontpage里的表单项:列表表单、列表域?我的软件上的两个选项是灰色的,无论怎样添加都出不来! 谢过了! 这里的值既可以物动输入,也可以下拉选择已有数据!
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
6 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
coffee_cn
2003-08-20
打赏
举报
回复
刚才贴的代码不能正常运行,现在修改了下:
<body onload="s1.focus();">
<script language="JavaScript">
<!--
function catch_keydown(sel)
{
switch(event.keyCode)
{
case 13:
//Enter;
sel.options[sel.length] = new Option("","",false,true);
event.returnValue = false;
break;
case 27:
//Esc;
alert("text:" + sel.options[sel.selectedIndex].text + ", value:" + sel.options[sel.selectedIndex].value + ";");
event.returnValue = false;
break;
case 46:
//Delete;
if(confirm("确定要删除吗?"))
{
sel.options[sel.selectedIndex] = null;
if(sel.length>0)
{
sel.options[0].selected = true;
}
}
event.returnValue = false;
break;
case 8:
//Back Space;
var s = sel.options[sel.selectedIndex].text;
sel.options[sel.selectedIndex].text = s.substr(0,s.length-1);
event.returnValue = false;
break;
}
}
function catch_press(sel)
{
sel.options[sel.selectedIndex].text = sel.options[sel.selectedIndex].text + String.fromCharCode(event.keyCode);
event.returnValue = false;
}
//-->
</script>
<form name=form1 action=selectok.asp>
<select name=s1 onkeydown="catch_keydown(this);" onkeypress="catch_press(this);" style="font-size:12px;"><option>---</option></select>
<BR>按回車輸入新內容,按DEL刪除選中內容
<br><input type=submit>
</form>
</body>
yyy431706
2003-08-20
打赏
举报
回复
对不起,代码应该是这样的,在onload事件中先隐藏文本框,然后用按钮的单击事件隐藏下拉框,显示文本框 。
<html>
<head>
<script language="javascript">
function show_text()
{
a.style.visibility="hidden";
b.style.visibility="visible";
}
function hidden_text()
{
b.style.visibility="hidden";
}
</script>
</head>
<body onload="hidden_text()">
<form>
<table>
<tr>
<td>
事故地段:
<div id="a" style="position:absolute; margin-left:0px; margin-top:-3px; width:350px; height:0px; z-index:0; background-color:; border: 0px; solid: #000000; padding:1px">
<select name="sgdd">
<option value="1" selected>1</option>
<option value="2">2</option>
<option value="3">3</option>
</select><input type="button" value="添加" onClick="show_text()">
</div>
<div id="b" style="position:absolute; margin-left:0px; margin-top:-3px; width:250px; height:0px; z-index:0; background-color:; border: 0px; solid: #000000; padding:1px">
<input name="sgdd_text" type="text">
</div>
</td>
</tr>
</table>
</form>
</body>
</html>
yyy431706
2003-08-20
打赏
举报
回复
我前几天也碰到这样的问题,这是我摸索出的一个解决方法,
如果下拉框中没有你所要的数据,
可在点点击添加按钮将下拉框隐藏,显示文本框进行输入.
主要用到css的相对定位和绝对定位实现。
我现在就用的是这个,有问题给我发消息。
<script language="javascript">
function show_text()
{
a.style.visibility="hidden";
b.style.visibility="visible";
}
</script>
<form>
<table>
<tr>
<td>
事故地段:
<div id="a" style="position:absolute; margin-left:0px; margin-top:-3px; width:350px; height:0px; z-index:0; background-color:; border: 0px; solid: #000000; padding:1px">
<select name="sgdd">
<option value="1" selected>1</option>
<option value="2">2</option>
<option value="3">3</option>
</select><input type="button" value="添加" onClick="show_text()">
</div>
<div id="b" style="position:absolute; margin-left:0px; margin-top:-3px; width:250px; height:0px; z-index:0; background-color:; border: 0px; solid: #000000; padding:1px">
<input name="sgdd_text" type="text">
</div>
</td>
</tr>
</table>
</form>
coffee_cn
2003-08-20
打赏
举报
回复
别人的例子
<body onload="s1.focus();">
<script language="JavaScript">
<!--
function catch_keydown(sel)
{
switch(event.keyCode)
{
case 13:
//Enter;
sel.options[sel.length] = new Option("","",false,true);
event.returnValue = false;
break;
case 27:
//Esc;
alert("text:" + sel.options[sel.selectedIndex].text + ", value:" + sel.options[sel.selectedIndex].value + ";");
event.returnValue = false;
break;
case 46:
//Delete;
if(confirm("确定要删除吗?"))
{
sel.options[sel.selectedIndex] = null;
if(sel.length>0)
{
sel.options[0].selected = true;
}
}
event.returnValue = false;
break;
case 8:
//Back Space;
var s = sel.options[sel.selectedIndex].text;
sel.options[sel.selectedIndex].text = s.substr(0,s.length-1);
event.returnValue = false;
break;
}
}
function catch_press(sel)
{
sel.options[sel.selectedIndex].text = sel.options[sel.selectedIndex].text + String.fromCharCode(event.keyCode);
event.returnValue = false;
}
//-->
</script>
<select name=s1 onkeydown="catch_keydown(this);" onkeypress="catch_press(this);" style="font-size:12px;"><option>---</option></select>
<BR>按回車輸入新內容,按DEL刪除選中內容
</body>
甘泉123
2003-08-20
打赏
举报
回复
楼上的好象答非所问,不过挺有用~~~
继续关注
zorou_fatal
2003-08-19
打赏
举报
回复
<%
Response.Write Request.Form("listvalues")
%>
<script>
function dellist()
{
if (window.form1.sel1.lastChild!="")
{
window.form1.sel1.removeChild(window.form1.sel1.lastChild);
}
}
function addtolist()
{
if( window.form1.txt1.value!="" )
{
window.form1.listvalues.value=window.form1.listvalues.value+window.form1.txt1.value+",";
myEle = document.createElement("option") ;
myEle.text = window.form1.txt1.value;
window.form1.sel1.add(myEle);
}
}
</script>
<script>
function listsubmit()
{
window.form1.submit()
}
</script>
<form id="form1" action="" method=post>
<select name="sel1">
<option>1</option>
<option>2</option>
<option>3</option>
</select>
<input type="hidden" name="listvalues">
<input type="text" name="txt1">
<input type="button" value="填入列表" onclick="addtolist()"><input type="button" value="提交" onclick="listsubmit()">
<input type="button" value="删除" onclick="dellist()">
</form>
程序天下:JavaScript实例自学手册
16.12 判断
表单
是否已修改 16.13 判断控件的类型 16.14 密码强度检查 16.15 身份证的验证 16.16 JavaScript生成验证码 16.17 JavaScript生成验证码(二) 第17章 进度条、滚动条特效处理 17.1 使用符号制作的进度条 ...
《程序天下:JavaScript实例自学手册》光盘源码
16.12 判断
表单
是否已修改 16.13 判断控件的类型 16.14 密码强度检查 16.15 身份证的验证 16.16 JavaScript生成验证码 16.17 JavaScript生成验证码(二) 第17章 进度条、滚动条特效处理 17.1 使用符号制作的进度条 ...
asp.net知识库
在.NET 2.0中,让你的组件也可以绑定 .NET20 一种简单的窗口控件UI状态控制方法 翻译MSDN文章 —— 泛型FAQ:最佳实践 Visual C# 3.0 新特性概览 C# 2.0会给我们带来什么 泛型技巧系列:如何提供类型参数之间的转换 ...
vue中如何做到
下拉
框
既有select功能也有input功能
vue中如何做到
下拉
框
既有select功能也有input功能
Extjs4.2控制combox
下拉
框
置空
Extjs4.2控制combox
下拉
框
置空需
求
具体描述思路具体代码其他 需
求
具体描述 ...假如现在有一个需
求
,需要我们既可以
选择
某个
下拉
数据
,也可以置空怎么办,在这里我提供一种思路,如果有其他更好的方...
ASP
28,391
社区成员
357,060
社区内容
发帖
与我相关
我的任务
ASP
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
复制链接
扫一扫
分享
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章