Home >Web Front-end >JS Tutorial >DynamicOptionList linked menu code_form effects
Please read the instructions before using it. It will not waste much time. Understanding it will help you quickly implement this small function. It is actually very simple and has nothing to do with the development language you use:
1.
This drop-down item can be retained or ignored, and the content such as "==View all==" can be replaced with your own needs content, the value="all" attribute can obtain an additional full filtering display function, it is recommended to retain it:)
2. Drop-down menu data format, (in actual development, a data format string can be generated by the background program, The format of this data string should be the same as the table structure you query. Just pass it to the template to get this data format string. All drop-down menu data is passed to the page at once, and has nothing to do with the language development and implementation you use. , as long as you find a way to get this string format) as follows:
a. The drop-down option of the first-level linked menu, the format is (drop-down option option content, drop-down option option value;.... ..)
"Shanghai,01;Jiangxi,02";
b. The drop-down options of the second-level linked menu, (sub-drop-down option option filter value, sub-drop-down option option content , sub-drop-down option option value;...)
"01,Xuhui District,001;01,Jiading District,002;01,Huangpu District,003;02,Nanchang City,004;02 ,Jiujiang City,005;02,Shangrao City,006";
c. The drop-down options of the third-level linked menu, (sub-drop-down option option filter value, sub-drop-down option option content, sub-drop-down option option Value;...)
"001, Xuhui District 1, 0001; 002, Jiading District 1, 0002; 003, Huangpu District 1, 0003; 004, Nanchang City 1, 0004; 005, Jiujiang 1 City, 0005; 006, Shangrao 1 City, 0006"; Option content, sub-drop-down option option value;...)
Except for the first level, which does not have sub-drop-down option option filter value, other subsets have sub-drop-down option option filter value
3. N-level linked menus can actually be realized, as long as the current menu drives its submenus, similar to the chain of responsibility model;
4. Actual development will< ;head> ... Put the three methods in a separate script file and introduce it. Just call the method on the page. In this way, you will find that it is very simple to implement this function. The method is also very natural;
5. Four examples are given below. They are actually the same, but the names and styles are different. The name suffix ('_' underscore is used as the separator for the suffix) is not necessary;
Copy code