I’m new here and new to php.
I searched for this exact problem, but couldn’t find anything proper for my problem.
I am writing a wordpress plugin where I am creating the working schedule for employees. I just finished my vacation tool where the employees can take their vacations. These gets written into a database table.
In the second tool where I am creating the schedule, I have a simple form with html, js and php where I am first selecting then date and time (as shown in the code below) and after that picking the employee from a dropdown list (also the code below). Now I want the employee only show up if he isn’t on vacation at this date from the first input field.
I know that php is server sided and can not solve this problem properly, so how could I manage this with js or even jquery?
Code for datetime selection: (just simple input)
<input type="datetime-local" name="date" required/>
Code for select option field:
<?php
global $wpdb;
$result = $wpdb->get_results("SELECT * FROM wp_einteilung_referees WHERE license_type ='Hauptschiedsrichter'");
?>
<select name="hsr1" class="require_3">
<option value="" disabled selected>Select HSR1</option>
<?php foreach($result as $value){ ?>
<option value="<?php echo $value->lastname; ?>"><?php echo $value->lastname; ?></option>
<?php } ?>
</select>
You can use ajax with jquery to resolve this problem.
<script type="text/javascript">
$(document).ready(function(){
$('#dateid').on('change',function(){
var seldate= $(this).val();
if(seldate!=''){
$.ajax({
type:'POST',
url:'pathtophppage.php',
data:'var='+valuetoserver,
success:function(html){
$('#id').html(html);
}
});
}
});