国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > AJAX > 正文

ajax實現輸入框文字改變展示下拉列表的效果示例

2024-09-01 08:28:48
字體:
來源:轉載
供稿:網友
1.樣式
代碼如下:
<style type="text/css">
<!--
body{background:#fff}
.Menu {
position:relative;
width:180px;
height:120px;
z-index:1;
background: #EEE;
border:1px solid #666;
margin-top:-100px;
display:none;
}
.Menu2 {
position: absolute;
left:0;
top:0;
width:100%;
height:120px;
overflow:hidden;
z-index:1;
OVERFLOW-y:auto;
}
.Menu2 ul{margin:0;padding:0}
.Menu2 ul li{width:100%;height:25px;line-height:20px;text-indent:15px;
border-bottom:1px dashed #999;color:#333;cursor:pointer;
change:expression(
this.onmouseover=function(){
this.style.background="";
},
this.onmouseout=function(){
this.style.background="";
}
)
}
input{width:120px}
#List1,#List2{left:0px;top:103px;}
-->
</style>

2. html腳本
代碼如下:
........省略常規腳本

<tr>
<th>汽車品牌名:</th>
<td>
<input type="text" id="generalBrandName" name="generalBrandName" value="${*.generalBrandName}" style="width:180px" data-validation-engine="validate[required]" <c:if test="${!empty carType.brandIdGeneral}"> disabled="disabled" </c:if> onfocus="showAndHide('List1','show');" onblur="showAndHide('List1','hide');"/>
<input type="hidden" id="brandIdGeneral" name="brandIdGeneral" value="${*.brandIdGeneral}" style="width:180px" />
<span class="required">必填*</span>
<div class="Menu" id="List1">
<div class="Menu2" id="ListLi1">
<%-- <ul>--%>
<%-- <li onmousedown="getValue('generalBrandName','寶馬','brandIdGeneral','idx');showAndHide('List1','hide');">寶馬</li>--%>
<%-- <li onmousedown="getValue('generalBrandName','奧迪','brandIdGeneral','idx');showAndHide('List1','hide');">奧迪</li>--%>
<%-- </ul>--%>
</div>
</div>

</td>
</tr>

........省略常規腳本
<tr>
<th>汽車廠商名:</th>
<td>
<input type="text" id="brandName" name="brandName" value="${*.brandName}" style="width:180px" data-validation-engine="validate[required]" <c:if test="${!empty carType.brandId}"> disabled="disabled" </c:if> onfocus="showAndHide('List2','show');" onblur="showAndHide('List2','hide');" />
<input type="hidden" id="brandId" name="brandId" value="${*.brandId}" style="width:180px" />
<span class="required">必填*</span>
<div class="Menu" id="List2">
<div class="Menu2" id="ListLi2">
</div>
</div>

</td>
</tr>

3.通過JS來實現ajax異步請求 根據輸入的內容過濾
代碼如下:
//頁面加載的時候

jQuery(function($) {
if (navigator.userAgent.indexOf("MSIE") > 0) {
document.getElementById('generalBrandName').attachEvent("onPropertyChange", appendList);
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 台湾省| 深圳市| 明光市| 高阳县| 太原市| 嘉祥县| 延庆县| 吉林省| 河南省| 井冈山市| 东源县| 叶城县| 佛坪县| 马尔康县| 天津市| 郁南县| 吉木乃县| 鄂托克前旗| 沽源县| 玉林市| 佛冈县| 平利县| 咸宁市| 中西区| 阜平县| 武平县| 鹤山市| 杂多县| 张北县| 东乌| 台北县| 高邑县| 汉沽区| 兴隆县| 吴忠市| 湛江市| 贵南县| 繁峙县| 康定县| 曲周县| 永修县|