Super simple JS Code linkage, but to be used with jquery, you can also modify the code of the JS library by yourself.
Copy codeThe Code is as follows:
<Tr>
<Th> Level 1 Classification </th> <td>
<Select name = "subsidiary_cat_id" class = "subsidiary_cat_id" onchange = "linkage ('. subsidiary_cat_id', '. cat_id');">
<Option> select </option>
</Select>
<Script language = "javascript">
Var linkage_data = {$ list_file_category}; // initialize cascade data. {$ list_file_category} is the JSON_ENCODE data of PHP. The array has three pieces of data: id, parent_id, name
Function linkage (parent_dom, son_dom ){
Var parent_id = 0;
If (parent_dom ){
Parent_id = $ (parent_dom). val ();
}
$ (Son_dom). empty (); // clear the drop-down list first.
Var html = '<option> select </option> ';
$. Each (linkage_data, function (key, value ){
If (value. parent_id = parent_id ){
Html + = "<option value = '" + value. id + "'>" + value. name + "</option> ";
}
});
$ (Son_dom). append (html );
}
Linkage ('',". subsidiary_cat_id ") // if no parent node is uploaded, the first level of data is returned.
</Script>
</Td> </tr>
<Tr> <th> Level 2 Directory </th> <td>
<Select name = "cat_id" class = "cat_id">
<Option> select </option>
</Select> </td> </tr>