- <!doctype html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport"
- content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
- <meta http-equiv="X-UA-Compatible" content="ie=edge">
- <title>Document</title>
- <script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
- </head>
- <body dir="rtl">
- <div id="colleges">
- <input type="checkbox" id="college_all">همه دانشکده ها
- <?php
- /**
- * Created by PhpStorm.
- * User: mahdi
- * Date: 1/6/19
- * Time: 8:03 AM
- */
- include_once('college.php');
- ?>
- </div>
- <div id="groups">
- <input type="checkbox" disabled id="group_all">همه گروه ها
- </div>
- <div id="majors">
- <input type="checkbox" disabled id="major_all">همه رشته ها
- </div>
- <script>
- $("#college_all").click(function () {
- var checked = this.checked;
- $(".college").each(function(){
- if (this.checked != checked) $(this).trigger('click');
- })
- })
- $("#group_all").click(function () {
- var checked = this.checked;
- $(".group").each(function(){
- if (this.checked != checked) $(this).trigger('click');
- })
- })
- $("#major_all").click(function () {
- var checked = this.checked;
- $(".major").each(function(){
- if (this.checked != checked) $(this).trigger('click');
- })
- })
- $(".college").change(function () {
- if (this.checked) {
- $("#group_all").removeAttr("disabled");
- val = $(this).val();
- if(val){
- $.ajax({
- type: "GET",
- url: 'getgroup.php?collegeid=' + val,
- success: function (data) {
- $("#groups").append(data);
- $(".group").change(function () {
- if (this.checked) {
- $("#major_all").removeAttr("disabled");
- val1 = $(this).val();
- if(val1){
- $.ajax({
- type: "GET",
- url: 'getmajor.php?groupid=' + val1,
- success: function (data) {
- $("#majors").append(data);
- }
- })
- }
- } else {
- v = $(this).val();
- gclass = ".groupid" + v;
- // alert(gclass);
- $(gclass).remove();
- }
- })
- }
- })
- }
- } else {
- v1 = $(this).val();
- cclass = ".collegeid" + v1;
- // alert()
- $(cclass).remove();
- }
- })
- </script>
- </body>
- </html>
ajax.php