jQuery DatePicker

Using jQuery DatePicker in JSP and PHP

In jQuery DatePicker tutorial, we show how to use the jQuery DatePicker component. The chosen date is displayed in a in Java JSP and PHP pages.

is a fast, small, and feature-rich JavaScript library. It makes HTML document traversal and manipulation, event handling, animation, and Ajax much simpler with an easy-to-use API that works across a multitude of browsers. is a set of user interface widgets, effects, interactions, and themes built on top of the jQuery Library.

DatePicker is one of the UI widgets of the jQuery UI library. It is used for selecting a date value.

Java web application

In the following example, we use a DatePicker component to select a date. The selected date is sent and displayed in a JSP page.

              

In the index.html file, we use the DatePicker component in a form tag. The action attribute points to the showDate.jsp page.

We include the JavaScript libraries and CSS styles for the DatePicker component.

The DatePicker component is created.

The DatePicker is tied to this input tag.
        

The chosen date is

In the showDate.jsp file, the selected date is printed.

PHP application

The next instructions show how to adapt the example for a PHP application.

The form’s action attribute points to the showDate.php file.

jQuery DatePicker

The date is printed. Figure: jQuery DatePicker

In this tutorial, we have used jQuery DatePicker in a Java web and PHP applications.

Источник

Laravel Livewire Crud with Bootstrap Modal Example

Hello Friends, In this blog, I would like to share with you how perform crud opeartion with bootstrap modal livewire in laravel application.I will.

How to use Datepicker in PHP?

I am going to explain you How to use Datepicker in PHP. You will learn How to make a nice «date picker» in PHP?. In side this article we will see How To Use Bootstrap Datepicker in PHP & MySQL.

This article will give you simple example of How To Use Bootstrap Datepicker in PHP . We will use get simple How to Add Datepicker in PHP Form with PHP date picker class.

I will give you simple Example of How to use Datepicker in PHP.

So, let’s see bellow solution:

connection.php

connect_error)< die ('connection faild:'.$conn->connect_error); > ?>
 ?>        .error  

How to use Datepicker in PHP

*
*
*
*
 if (empty($last_name)) < $error['last_nameErr'] = "last name is required!"; >if (empty($admission_date)) < $error['admission_dateErr'] = "admission date is required!"; >if (!empty($error)) < $_SESSION['errors'] = $error; $_SESSION['post'] = $_POST; header('location:index.php'); >if (empty($error))< include "connection.php"; $sql = "INSERT INTO students (first_name,last_name,email,address,admission_date) VALUES('$first_name','$last_name','$email','$address','$admission_date')"; if ($conn->query($sql)===TRUE) < $_SESSION['msg'] = "
Data Insert Successfully
"; header('location:index.php'); >else< $_SESSION['msg'] = "
Error: ".$sql."
".$conn->error."
"; header('location:index.php'); > $conn->close(); >else < header('location:index.php'); >> ?>

Output:

✌️ Like this article? Follow me on Twitter and Facebook. You can also subscribe to RSS Feed.

You might also like.

Источник

How To Use Bootstrap Datepicker in PHP & MySQL using Ajax

In this tutorial, I will explain how to implement Bootstrap Datepicker in PHP & MySQL using Ajax. I will guide you step by step on how it works. So in this example, we will create a function that asks the users about their date of birth.

With the help of Bootstrap Datepicker, we enable a quick process with an excellent user interface instead of doing it from scratch or just using the native date picker on chrome which doesn’t support other browsers.

Bootstrap Datepicker

So before we continue in this tutorial, I will let you know that we are using Bootstrap 4, jQuery 3.5.1, and Bootstrap Datepicker.

Index.html File

Here is the complete source code of our index.html

         


How To Use Bootstrap Datepicker in PHP & MySQL using Ajax



Script.js File

Next, our javascript called scripts.js from the imported the above code. Kindly check each line’s comment for you to understand the process.

$(document).ready(function() < // Initialize the datepicker $('.date').datepicker(< todayHighlight: true, // to highlight the today's date format: 'yyyy-mm-dd', // we format the date before we will submit it to the server side autoclose: true //we enable autoclose so that once we click the date it will automatically close the datepicker >); $("#btnSubmit").on("click", function() < var $this = $("#btnSubmit"); //submit button selector using ID var $caption = $this.html();// We store the html content of the submit button var form = "#form"; //defined the #form ID var formData = $(form).serializeArray(); //serialize the form into array var route = $(form).attr('action'); //get the route using attribute action // Ajax config $.ajax(< type: "POST", //we are using POST method to submit the data to the server side url: route, // get the route value data: formData, // our serialized array data for server side beforeSend: function () , success: function (response) , error: function (XMLHttpRequest, textStatus, errorThrown) < // You can put something here if there is an error from submitted request >>); >); >);

Creating Database Table

Next, creating our database table. If you already created your database then we will continue to create our table «dob» as your table name. Here is the code below.

CREATE TABLE `dob` ( `id` int(11) NOT NULL, `dob` date NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

Process.php File

Next, our last code to process the saving of submitted data from our from.

 // Set the INSERT SQL data $sql = "INSERT INTO dob (dob) VALUES ('".$date."')"; // Process the query so that we will save the date of birth if (mysqli_query($conn, $sql)) < echo "New record created successfully."; >else < return "Error: " . $sql . "
" . mysqli_error($conn); > // Close the connection after using it mysqli_close($conn); ?>

Now you can enable to save data from the form with bootstrap datepicker using PHP and MySQL with Ajax.

I hope this tutorial can help you. Now you can download our code for you to test and run.

Источник

How to Make a Nice «date picker» in PHP?

In this post, we will learn How to make a nice «date picker» in PHP?. i explained simply step by step How To Use Bootstrap Datepicker in PHP & MySQL. Here you will learn How To Use Bootstrap Datepicker in PHP. This tutorial will give you simple example of How to Add Datepicker in PHP Form with PHP date picker class.

I will give you simple Example of How to make a nice «date picker» in PHP.

So let’s see bellow example:

connection.php

$servername = «localhost»;

$username = «root»;

$password = «root»;

$dbname = «aatman»;

$conn = new mysqli($servername,$username,$password,$dbname);

if($conn->connect_error) <

die (‘connection faild:’.$conn->connect_error);

>

?>

session_start();

if(isset($_SESSION[«msg»]) && !empty($_SESSION[«msg»]))

<

$msg=$_SESSION[«msg»];

echo $msg;

unset($_SESSION[‘msg’]);

session_destroy();

>

?>

.error

<

color: red;

>

$error = $_SESSION[‘errors’];

extract($error);

session_destroy();

?>

First Name :

Last Name :

Email :

Admission Date :

Address :

session_start();

if ($_SERVER[«REQUEST_METHOD»] == «POST») <

extract($_POST);

$error = array();

if (empty($first_name)) <

$error[‘first_nameErr’] = «first name is required!»;

>

if (empty($last_name)) <

$error[‘last_nameErr’] = «last name is required!»;

>

if (empty($admission_date)) <

$error[‘admission_dateErr’] = «admission date is required!»;

>

if (!empty($error)) <

$_SESSION[‘errors’] = $error;

$_SESSION[‘post’] = $_POST;

header(‘location:index.php’);

>

if (empty($error)) <

include «connection.php»;

$sql = «INSERT INTO students (first_name,last_name,email,address,admission_date)

VALUES(‘$first_name’,’$last_name’,’$email’,’$address’,’$admission_date’)»;

if ($conn->query($sql)===TRUE) <

$_SESSION[‘msg’] = «

Data Insert Successfully

«;

header(‘location:index.php’);

>else <

$_SESSION[‘msg’] = «

Error: «.$sql.»
«.$conn->error.»

«;

header(‘location:index.php’);

>

$conn->close();

>else <

header(‘location:index.php’);

>

>

?>

✌️ Like this article? Follow me on Twitter and Facebook. You can also subscribe to RSS Feed.

Источник

Читайте также:  Width based on content css
Оцените статью