Select date via datepicker

Asked

Viewed 76 times

0

Devs blz?

In my form I need to include a field to select date, I want to use a bootstrap datepicker or similar. It is a scheduling system where I make a query to the database to return the available times for the selected day.

The point is I’m doing this consultation with select... My question is how I can put a calendar in the select entry to do this query, so I know I can only call a calendar with input type='data'

    <label class="label">
    <span>Selecione um dia:</span>
    <select name="appointment_schedule_id" class="horarios">
        <option selected disabled value="">Nenhum Selecionado</option>
        <?php
        $read->readFull("SELECT 

                            *
        
                            FROM schedule s 
                            WHERE s.schedule_status IS NULL 
                                AND s.schedule_tstamp >= CURRENT_TIMESTAMP 
                            GROUP BY s.schedule_ref
                            ORDER BY s.schedule_tstamp ASC");
                            

        $schedules = ($read->getResult() ? $read->getResult() : null);

        if (!empty($schedules)) {
            foreach ($schedules as $schedule) {
                $schedule = (object) $schedule;
                echo "<option value='{$schedule->schedule_id}'>" . date('d/m/Y', strtotime($schedule->schedule_tstamp)) . "</option>";
            }
        }
        ?>
    </select>
</label>

I do not know if I understand, summarizing I need that in the select of the code above when clicking can be opening a calendar so that I can choose date for scheduling.

  • Guy already needed to do this once, in my case I used the Datepicker of Jquery UI, and loaded the database data via ajax request and inserted in the calendar, in the case of Datepicker of Jquery UI has to show it on the screen without needing an input.

  • https://jqueryui.com/datepicker/#inline

  • Opa so in your opinion you think I should take it select and search the database via ajax?

  • In my view it would be a good option, when selecting the date you would use the Datepicker trigger itself to search via ajax in the bank and fill your select with the available times for the selected day.

  • 1

    I’ll be trying this search via ajax, thanks for your attention.

  • @Gnomoescalate guy would have some example of this select ajax

Show 1 more comment
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.