怎样做一个可以输入的下拉列表(select)?

whan1234 2004-01-13 10:06:13
我想做一个下拉列表,初始状态是空白并可以输入,也可以从下拉列表的选择项目(option)里选一个作为输入,请问应该怎么做?输入的那个值可以被作为该下拉列表的value被提交到servlet吗?
...全文
187 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
zyzy15 2004-01-13
  • 打赏
  • 举报
回复
可以用层模拟
这个我瞎做着玩的,不太好看,你再改改 :)

<TABLE>
<TR>
<TD width="60">
<INPUT TYPE="text" NAME="t1" size="4"><INPUT TYPE="button" value="*" onclick="click1()">
<div id="d1" border="1" style="word-break: break-all; WORD-WRAP: break-word;cursor:hand;display:none">
<TABLE width="40" border=1 cellpadding=0 cellspacing=0 style="border-collapse:collapse">
<TR onmousedown="fun(1)"><TD>1</TD></TR>
<TR onmousedown="fun(2)"><TD>2</TD></TR>
<TR onmousedown="fun(3)"><TD>3</TD></TR>
<TR onmousedown="fun(4)"><TD>4</TD></TR>
<TR onmousedown="fun(5)"><TD>5</TD></TR>
<TR onmousedown="fun(6)"><TD>6</TD></TR>
<TR onmousedown="fun(7)"><TD>7</TD></TR>
<TR onmousedown="fun(8)"><TD>8</TD></TR>
<TR onmousedown="fun(9)"><TD>9</TD></TR>
<TR onmousedown="fun(10)"><TD>10</TD></TR>
<TR onmousedown="fun(11)"><TD>11</TD></TR>
<TR onmousedown="fun(12)"><TD>12</TD></TR>
</TABLE>
</div>
</TD>
</TR>
</TABLE></div>
<SCRIPT LANGUAGE="JavaScript">
<!--
function fun(num)
{
t1.value=num;
d1.style.display="none";
}
function click1()
{
if(d1.style.display=="none")d1.style.display="";
else d1.style.display="none";
}
//-->
</SCRIPT>
aoenzh 2004-01-13
  • 打赏
  • 举报
回复
不可能
可以用文本框
whan1234 2004-01-13
  • 打赏
  • 举报
回复
楼上谢了!2小时后揭帖!
kisslan 2004-01-13
  • 打赏
  • 举报
回复
楼主试试这个看!在输入框里输入值,再点add进行添加
<html>
<head>
<title>test</title>
</head>

<SCRIPT language="javascript" >
function oUser(text,value)
{
this.text=text;
this.value=value;
}
function addOption()
{
var theS = document.getElementById("hospital");
var str = document.all.edit_hospital.value;
oOption=new Option(str,str);
theS.add(oOption);

}
</SCRIPT>
<body>
<form name="form1" method="post" action="">
<tr>
<td align="right"><font color="#006600" style="position:absolute z-index:1">456:</font></td>
<td colspan="2">

<div style="position:absolute; width:100px; clip:rect(2px 98px 18px 82px); z-index:2; visibility: visible;">
<select name= "hospital" id = "hospital" onchange = "edit_hospital.value = this.value;edit_hospital.select()" style="width:100px"> </select>
</div>
<input name="edit_hospital" type="text" id = "edit_hospital" class = "in" autocomplete="off" style="width:100px; Z-INDEX:1; POSITION:absolute; visibility: visible;" />
</td>
</tr>
<br/>
<button onclick="addOption()">add</button>
</form>
</body>
</html>

whan1234 2004-01-13
  • 打赏
  • 举报
回复
真的不行吗?还有人知道吗?谢了!
birdtree 2004-01-13
  • 打赏
  • 举报
回复
好象不可以吧。
whan1234 2004-01-13
  • 打赏
  • 举报
回复
楼上的很有趣。

61,112

社区成员

发帖
与我相关
我的任务
社区描述
层叠样式表(英文全称:Cascading Style Sheets)是一种用来表现HTML(标准通用标记语言的一个应用)或XML(标准通用标记语言的一个子集)等文件样式的计算机语言。
社区管理员
  • HTML(CSS)社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧