Jquery implements level-2 cascading menus

Source: Internet
Author: User

Provides a simple jquery Implementation of level-2 cascade menu code download. After downloading the code, you can download a plug-in from jquery.

Provides a simple jquery Implementation of level-2 cascade menu code download. After downloading the code, you can download a plug-in from jquery.

<Script src = "../admin/js/jquery/jquery-1.2.6.js" type = "text/javascript"> </script>
<Script language = "javascript">
$ (
Function (){
$ ("# Collegeid"). change (
Function (){
$ ("# Professional"). load ("plugins/mycollege/mycollege_select.inc.php? Collegeid = "+ $ (" # collegeid "). val ());
}
);
}
);
</Script>

// Note that the names of all tags are based on id
<Select name = "collegeid" id = "collegeid">
<Option value = "0"> select a department </option>
<! -- {Loop $ all_colleges $ college} -->
<Option value = "$ college ['id']"> $ college ['name'] </option>
<! -- {/Loop} -->

</Select>
// The span tag in this area can be changed to div
<Span id = "professional">
<Select name = "professionalid" id = "professionalid">
<Option value = "0"> select a major </option>
</Select>
</Span>

3> the Load file outputs a file.
<? Php
Require_once '.../../include/common. inc. php ';
Require_once 'mycollege. function. php ';
// Determine whether the user is logged on
If (! $ Discuz_uid)
{
Showmessage ('not _ loggedin', 'logging. php? Action = login ');
}
// Here are some of my own database operations, which can be changed to my own data operations as needed
$ Collegeid = intval ($ collegeid );
$ Professionallist = getProfessionallist ($ collegeid );
Header ("Cache-Control: no-cache ");
$ Str = "<select name = 'your sionalid' id = 'your sionalid'> <option value = '0'> select a major </option> ";
If (! Empty ($ professionallist )){
Foreach ($ schemsionallist as $ value)
{
$ Str. = '<option value = "'. $ value [" id "]. '">'. $ value ["name"]. '</option> ';
}
}

$ Str. = '</select> ';
Echo $ str;
?>

Jquery plugin

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.