0

Ok, I'm lost. I've tried to work this out myself but it's beyond me.

I have a sign-up form where you will need to select a date from the bootstrap datepicker and then you will be presented with a list of time slots in a select menu. The times will be based on availability, and change in real time as different dates are chosen. So I'll have to query the mysql database to see what times are still available and the list them in the select menu. There are only 5 potential time slots per day, 5 days a week. Ideally I would then use the datepicker to disable those dates with no time slots left, but that may be outside the scope of this question. I'm sorry if this is vague, I'm really at my wit's end.

So here's what I have for the datepicker

<script>
        $(document).ready(function(){
        var date_input=$('input[name="date"]');
        var container=$('.bootstrap-iso form').length>0 ? $('.bootstrap-iso form').parent() : "body";
        var options={
            format: 'yyyy-mm-dd',
            container: container,
            todayHighlight: false,
            autoclose: true,
            };
        date_input.datepicker(options).on('changeDate', function(e) 
        {
          var seldate=(e.format(0,"yyyy-mm-dd"));  
        });         
        });
    </script>

And a very basic select list with all of the potential time slots.

        <select name="timeslot">
            <option value="9:30">9:30</option>
            <option value="9:30">10:30</option>
            <option value="9:30">11:30</option>
            <option value="9:30">2:00</option>
            <option value="9:30">3:00</option>
        </select>

The DB will have one entry per date, with the time slots as bool (taken or not). I've never really worked with jquery or Ajax much, but I assume that's where I need to go. I'm totally open to links that at least point me in the right direction.

Sorry if this is an off-the-rails question.

Jonah
  • 1
  • You should use a backend language to interact with your DB. Take a look here [How to connect to SQL Server database from JavaScript in the browser?](https://stackoverflow.com/questions/857670/how-to-connect-to-sql-server-database-from-javascript-in-the-browser) – Dwhitz Jul 11 '17 at 20:04
  • That link shows how to connect with JS, but goes on to explain why you shouldn't do that. It doesn't really explain how to go about doing correctly. – Jonah Jul 11 '17 at 20:12

0 Answers0