日期:2014-05-16  浏览次数:20434 次

既可以输入又可以选择菜单 JavaScript
例子1
<%@ page contentType="text/html;charset=utf-8"%>
<script language="javascript">
function add(val) {
        var all = document.getElementById("n";
        var max = all.options.length;
                if(val.replace(/(\s+)/,'')==''){
             return;
                }
        for (var i=0;i<max;i++) {
            if (all.options.text==val) {
                 return;
            }  
        }
                all.options.add(new Option(val));
    }
</script>
<form name="form1">
<input type="text" size="20" name="m" value="hello"  onPaste="alert('请手工输入');return false" onBlur="add(this.value)" >
<select name="n" onChange="this.form.m.value=this.options[selectedIndex].text" id="n">
<option>hello</option>
<option>a</option>
</select>
</form>

引自:http://www.itpub.net/thread-714454-1-1.html#

例子2
<%@ page contentType="text/html;charset=utf-8"%>

<%String aa = request.getParameter("txtPlace");out.println(aa); %>
<form>
<table>
<tr>
<td style="font-size: 12px;">&nbsp;</td>
<td valign="top">
<select name="myselect" style=" width:220; position:absolute;clip: rect(2 100% 90% 201)" onchange="document.getElementById('txtPlace').value=this.value">
<option value=""> </option>
<option value="1"> 蓝色经典 </option>
<option value="2"> 织梦地带 </option>
<option value="3"> 联盟论坛 </option>
<option value="4"> 无忧脚本 </option>
</select>
<input name="txtPlace" type="text" size="32" style="font-size:12px; border: none; border-bottom: 1px solid #a0a0a0; background-color:transparent;"> 
</td>
</tr>
</table>
<input type="submit" value="提交">
</form>

引自:http://blog.csdn.net/bjbs_270/archive/2005/08/10/449856.aspx