Topic: How to pass date from datepicker to php

capitalit priority asked 3 years ago


I have a google API plugin I have coded that pulls analytics data for a website. I have passed the analytics data to the UI dashboard successfully using session_start(); and these variables: //On page 1 (Googleapi.php) $_SESSION['varname'] = $var_value;

//On page 2 (UI Dasboard.php) - This is where the datepicker is $var_value = $_SESSION['varname'];

What I cannot get to happen is to get the date from datepicker and use it as a variable on "page 1" which is the google api.php file.

Expected behavior Choose the start date and end date with datepicker and this passes the dates as a variable to php. Actual behavior No data is passed from datepicker to googleAPI.php Resources (screenshots, code snippets etc.) Here is the snippet of the UI dashboard. It is mostly the UI design provided in the pro package as is. Snippet: https://mdbootstrap.com/snippets/standard/capitalit/2851595


Grzegorz Bujański staff answered 3 years ago


It can stay in the same place as it is added in the snippet. You also don't need to initialize the timepicker first and set options later. You can set options right on initialization.


capitalit priority answered 3 years ago


Thanks for getting back with me. I have added the closing form tag to my code (not the snippet). Where do I init the datepicker though and choose options? So If I would like to set the default date? Example:

$(document).ready(function({
    $('#textboxname').datepicker();
    $('#textboxname').datepicker('setDate', 'today');
});

Grzegorz Bujański staff answered 3 years ago


The code you pasted into the snippet contains errors that may cause it to malfunction - e.g. unclosed form tag:

<div class="col-md-3">
  <div class="form-outline datepicker">
    <input type="text" class="form-control" id="exampleDatepicker1" name="date1" data-toggle="datepicker" value="Start Date" />
    <label for="exampleDatepicker1" class="form-label">Date</label>
  </div>
  <form action="reservations_per_day.php" method="post">
</div>

and commented out variable:

<! - Variable format for html doc
$ var_value = $ _SESSION ['varname'];
 ->

There is no special method to get value from the datepicker. The datepicker will contain the input from which you just need to get value. Do you have any errors in the console after selecting start date and end date?



Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Answered

Specification of the issue

  • ForumUser: Priority
  • Premium support: Yes
  • Technology: MDB Standard
  • MDB Version: 3.0.0
  • Device: N/A
  • Browser: Chrome
  • OS: Windows
  • Provided sample code: No
  • Provided link: Yes