JSFiddle - React, Tailwind, and code Playground

by doug65536

JavaScript

function checkdts() {
    var arr = ["1", "2", "3", "4", "5", "6", "7"];

    $.each(arr, function (i, val) {

        var x = $('select#select_grade_set_' + val).val();

        if (x == 'Pre-K' || x == 'K' || x == '1st') {
            $('#gp_set_1').show();
            $('#gp_set_4').show();
            var value_pk1_students = 0;
            $("#select_grade_limit_both input").each(function () {
                var i = parseInt($(this).val());
                if (!isNaN(i)) {
                    value_pk1_students += i;
                }
            });
               //alert('pk-1');
        } else if (value_pk1_students >= 100) {
      
            $('#gp_set_1').hide();
            $('#gp_set_4').hide();
        }
    });

    $.each(arr, function (i, val) {

        var x = $('select#select_grade_set_' + val).val();

        if (x == '2nd' || x == '3rd' || x == '4th' || x == '5th') {
            $('#gp_set_2').show();
            $('#gp_set_4').show();
            $("#select_grade_limit_both input").each(function () {
                var i = parseInt($(this).val());
                if (!isNaN(i)) {
                    value_k5_students += i;
                }
            });
            //alert('2-5');
        } else if (value_k5_students >= 100) {
            $('#gp_set_2').hide();
            $('#gp_set_4').hide();
        }
    });


    $.each(arr, function (i, val) {

        var x = $('#select_grade_limit_6_12 select#select_grade_set_' + val).val();

        if (x == '6th' || x == '7th' || x == '8th' || x == '9th' || x == '10th' || x == '11th' || x == '12th') {

            $('#gp_set_3').show();
            $('#gp_set_4').show();
            $("#gp_set_3 .gps1").append('<select id="gp_choice_2" name="6_12_gp_choice_2" class="sel-3"> <option value="" selected="selected">Choose</option><option class="select" value="One">One</option></select>');
            $("#gp_set_3 .gps2").append('<select id="gp_choice_2" name="6_12_gp_choice_2" class="sel-3">...