HTML code
1 <Divclass= "Navbar-form navbar-left"role= "Search"ID= "Schoolconfig">3 <span class='Form-group-addon ' style= "FONT-SIZE:16PX;" > Choose a school:</span>4 <Div class="Form-group"ID="Schoolquery"style="position:relative;">5 <SPAN style="Margin-left:100px;width:18px;overflow:hidden;">6 <SelectID="SchoolID"style="width:118px;margin-left:-100px"onchange="SetValue (This)"></Select>7 </span>8 <Input ID="Schoolname"class="Form-control"placeholder="School Name"style="width:100px;position:absolute;left:0px;top:0px;height:30px;"onblur="reloadsection ()">9 </Div>Ten </Div>
JS Code
1 /**2 * Place the value of select into the input box3 */4 functionSetValue (obj) {5 varindex = Obj.selectedindex;//Check Index6 varvalue = Obj.options[index].value;//checked Values7 varSchoolname = Obj.options[index].text;//Select text8$ (' #schoolName '). Val (schoolname); One}
1$.getjson (//Get School Data2'/test/manage/user/school_findallname.action ',3 function(data) {4$ ("#schoolName"). AutoComplete ({5 Source:data6 });7 }8 );9Initcombo ($ (' #schoolId '), '/test/manage/user/school_findallidandschoolname.action ', ' schoolid ', ' schoolname ');
1 /**2 * Init combobox3 * @return {}4 */5 functionInitcombo (Combo,url,valuefield,displayfield) {6 $.getjson (7 URL,8 function(data) {9 if(Data.rows && data.rows.length>0){Ten varhtml = ' <option></option> ', Onerows =Data.rows, ALen =rows.length; - - for(vari=0; i<len; i++) theHTML + = "<option value=" + Rows[i][valuefield] + ">" + Rows[i][displayfield] + "</option>"; - combo.html (HTML); - } - } + ); -}
Select to implement input fuzzy matching and select dual function