Untitled

mail@pastecode.io avatar
unknown
plain_text
2 months ago
6.2 kB
2
Indexable
Never
{% if wizard.steps.current == '1' %}

            var validDiscipline = [];
            var validQualification = [];
            
            $.ajax({
                type: "GET",
                url: "{% url 'registrationForm:discipline-ajax'%}",
                cache: false,
                success: function (data) {
                    var datalist = $('#discipline');
                    for (var key in data) {
                        if (data.hasOwnProperty(key)) {
                            var option = $('<option>', {
                                value: data[key],
                                text: data[key]
                            });
                            datalist.append(option);
                            validDiscipline = Object.values(data);
                        }
                    }
                },
                async: false,
            });

            $('#id_1-discipline').on('focusout', function() {
                var inputText = $(this).val().trim();
                
                if (validDiscipline.indexOf(inputText) === -1 && inputText) {
                    showToast('Please select a proper discipline from the list', 'toastContainer1');
                    $(this).val('');
                } else {
                    OtherBox(this);
                }
            });

            $.ajax({
                type: "GET",
                url: "{% url 'registrationForm:qual-category-ajax1'%}",
                cache: false,
                success: function (data) {
                    var datalist = $('#qualification');
                    for (var key in data) {
                        if (data.hasOwnProperty(key)) {
                            var option = $('<option>', {
                                value: data[key],
                                text: data[key]
                            });
                            datalist.append(option);
                            validQualification = Object.values(data);
                        }
                    };
                },
                async: false,
            });

            $('#id_1-degree').on('focusout', function() {
                var inputText = $(this).val().trim();
                
                if (validQualification.indexOf(inputText) === -1 && inputText) {
                    showToast('Please select a proper qualification from the list', 'toastContainer1');
                    $(this).val('');
                } else {
                    OtherBox(this);
                }
            });

            {% endif %}

            {% if wizard.steps.current == '2' %}

            var validIndustries = [];
            var validLocation = [];
            
            $.ajax({
                type: "GET",
                url: "{% url 'registrationForm:industry-ajax'%}",
                cache: false,
                success: function (data) {
                    var datalist = $('#industry');
                    for (var key in data) {
                        if (data.hasOwnProperty(key)) {
                            var option = $('<option>', {
                                value: data[key],
                                text: data[key]
                            });
                            datalist.append(option);
                            validIndustries = Object.values(data);
                        }
                    }
                },
                async: false,
            });

            $('#id_2-current_org_industry').on('focusout', function() {
                var inputText = $(this).val().trim();
                
                if (validIndustries.indexOf(inputText) === -1) {
                    showToast('Please select a proper industry from the list', 'toastContainer');
                    $(this).val('');
                }
            });

            $.ajax({
                type: "GET",
                url: "{% url 'registrationForm:location-ajax'%}",
                cache: false,
                success: function (data) {
                    var datalist = $('#location');
                    for (var key in data) {
                        if (data.hasOwnProperty(key)) {
                            var option = $('<option>', {
                                value: data[key],
                                text: data[key]
                            });
                            datalist.append(option);
                            validLocation = Object.values(data);
                        }
                    }
                },
                async: false,
            });

            $('#id_2-work_location').on('focusout', function() {
                var inputText = $(this).val().trim();
                
                if (validLocation.indexOf(inputText) === -1) {
                    showToast('Please select a proper location from the list', 'toastContainer');
                    $(this).val('');
                }
            });

            {% endif %}



function QualCategory() {
            let select_id = $("#id_1-qual_cat").val();

            // Clear values related to the selection
            $("#id_1-degree").val('');
            let select_input = $("#id_1-other_degree");
            select_input.attr("type", "hidden");
            select_input.removeAttr("required");
            select_input.val('');

            $.ajax({
                type: "GET",
                url: "{% url 'registrationForm:qual-category-ajax'%}",
                data: { 'select_id': select_id },
                cache: false,
                success: function (data) {
                    var datalist = $('#qualification');
                    datalist.empty();

                    for (var key in data) {
                        if (data.hasOwnProperty(key)) {
                            var option = $('<option>', {
                                value: data[key],
                                text: data[key]
                            });
                            datalist.append(option);
                        }
                    }

                    // Additional code that relies on the updated options can go here
                },
            });
        }
Leave a Comment