In this paper, we analyze the implementation method of jquery Select Automatic selection function. Share to everyone for your reference, specific as follows:
Filter
var typeid = "<!--{$typeid}-->";
var bigclassid = "<!--{$bigclassid}-->";
var smallclassid = "<!--{$smallclassid}-->";
$ ("#typeid option[value=" +typeid+ "]"). attr ("selected", true);
$ ("#typeid"). Change ();
$ ("#bigclassid option[value=" +bigclassid+ "]"). attr ("selected", true);
$ ("#bigclassid"). Change ();
$ ("#smallclassid option[value=" +smallclassid+ "]"). attr ("selected", true);
When you get a value, the setting is automatically selected.
When selected, calls the change () method. The Change method displays the next level of the Select box. Then select, and then call the change () method. This shows the three-level select box and is selected by default.
$ (document). Ready (function () {//ajax level $ ("#typeid"). Change (function () {var id = $ (this). Val ();
Setbigclass (ID);
});
$ ("#bigclassid"). Change (function () {var id = $ (this). Val ();
Setsmallclass (ID);
});
$ ("#screen_submit"). Click (function () {$ ("#screenform"). Submit ();
});
});
function Setbigclass (ID) {var res = Ajaxgetbigclass (ID);
if (res) {myobj = eval (res);
var strhtml= "<option value=0> all major categories </option>"; for (Var i=0;i<myobj.length;i++) {strhtml+= "<option value=" "+myobj[i].id+" ' > "+myobj[i].name+" </option
> ";
$ ("#bigclassid"). HTML (strhtml);
$ ("#bigclassid"). Show (). change ();
}else{$ ("#bigclassid"). html (' <option value= ' "></option> '). Hide ();
$ ("#smallclassid"). html (' <option value= ' "></option> '). Hide ();
} function Setsmallclass (ID) {var res = Ajaxgetsmallclass (ID);
if (res) {myobj = eval (res); var strhtml= "<optionvalue=0> all subcategories </option> "; for (Var i=0;i<myobj.length;i++) {strhtml+= "<option value=" "+myobj[i].id+" ' > "+myobj[i].name+" </option
> ";
$ ("#smallclassid"). HTML (strhtml);
$ ("#smallclassid"). Show ();
}else{$ ("#smallclassid"). html ('). Hide ();
}
}
More interested readers of jquery-related content can view the site topics: "jquery form (form) Operation Tips Summary", "jquery common Plug-ins and Usage summary", "JQuery Extended Skills Summary", "jquery switching effects and techniques summary", " jquery traversal algorithm and techniques summary, "jquery Common Classic Effects Summary", "jquery animation and special effects usage Summary" and "jquery Selector usage Summary"
I hope this article will help you with the jquery program design.