<?php

include "classes/html.class.php";

$html = new html("j.c. type");
?>



<div class='form'>
    <h2 style="font-size:2vw">ADD JOB CARD TYPE:</h2>
    <hr><br>
    <input type='text' placeholder="NAME" id='name' class='form_input' /><br><br>
    <label style="font-size:1.5vw">TRIGGER WARNING EVENT ON OPEN?</label> <br><br>
    <select class='form_input' id='warning'>
        <option>NO</option>
        <option>YES</option>
    </select><br><br>
    <input type='submit' value='ADD' class='form_btn' onclick='ajax_func()' />

</div>

<script>
    function ajax_func() {
        // alert("Test");
        name = document.getElementById('name').value;
        warning = document.getElementById('warning').value;

        // Create an XMLHttpRequest object
        const xhttp = new XMLHttpRequest();
        // Define a callback function
        xhttp.onload = function() {
            // Here you can use the Data
            if (this.responseText != 1) {

                alert(this.responseText);

            } else {
                alert('ADDED');
                window.location.href = "add_jobcard_type.php";
            }
        }

        xhttp.open("GET", "ajax/add_jobcard_type.ajax.php?name=" + name + "&warning=" + warning);
        xhttp.send();

    }
</script>


</body>

</html>