Topic: JavaScript

Chosen Ajax Autocomplete Textbox using jQuery, PHP 0

Chosen Ajax Autocomplete Textbox using jQuery, PHP and MySQL

Today, We want to share with you Chosen Ajax Autocomplete Textbox using jQuery, PHP and MySQL.In this post we will show you Autocomplete Textbox using jQuery, PHP and MySQLi, hear for Ajax PHP MySQL Creating Autocomplete Search Suggestion we will give you demo and example for implement.In this post, we will learn about PHP Autocomplete Input tags with Dynamic Data using jquery Ajax
with an example.

Chosen Ajax Autocomplete Textbox using jQuery, PHP and MySQL

There are the Following The simple About Chosen Ajax Autocomplete Textbox using jQuery, PHP and MySQL Full Information With Example and source code.

As I will cover this Post with live Working example to develop Jquery Chosen plugin – dynamically populate list by Ajax, so the PHP – Jquery Chosen Ajax Autocomplete for this example is following below.

Step 1: Make a MySQL Database Table

Lest start, I want to make MySQL database and table, therefor here i made “products” database and “products” table with product id as well as product name column. We can simply make MySQL “products” table as following simple sql query.

SQL Query:

CREATE TABLE IF NOT EXISTS `products` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci AUTO_INCREMENT=24 ;

Step 2: Make index.php

Now, I want to make simple root PHP index.php file as well as i made form with one HTML input text box using jquery chosen. I also some easy source code for multiple add more fields in jquery examples. therefor let’s make simple index.php file and put some bellow source code.

index.php

<!DOCTYPE html>
<html>
<head>
  <title>jQuery Chosen autocomplete with PHP and AJAX - pakainfo.com</title>
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css" />

 
  <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/chosen/1.8.7/chosen.css" />
  <script src="https://cdnjs.cloudflare.com/ajax/libs/chosen/1.8.7/chosen.jquery.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>
</head>
<body>

<h1>jQuery Chosen autocomplete with PHP and AJAX</h1> 
<div class="container pakainfo">
  <div class="pakainfo panel panel-primary">
    <div class="panel-heading">jQuery Chosen autocomplete with PHP and AJAX - pakainfo.com</div>
    <div class="panel-body pakainfo">
      <form>
        <select class="form-control pakainfo select-box">
          <option>Select Products</option>
        </select>
      </form>
    </div>
  </div>
</div>
 
<script type="text/javascript">
  $(".select-box").chosen();
 
  $('.chosen-search input').autocomplete({
    source: function( request, response ) {
      $.ajax({
        url: "request_ajax.php?name="+request.term,
        dataType: "json",
        success: function( data ) {
          $('.select-box').empty();
          response( $.map( data, function( product ) {
            $('.select-box').append('<option value="'+product.id+'">' + product.name + '</option>');
          }));
          $(".select-box").trigger("chosen:updated");
        }
      });
    }
  });
</script>
 
</body>
</html>

Step 3: Create request_ajax.php File

In this Last step, I shall simple source code for fetching PHP jquery ajax data from MySQL database using simple mysql query. Therefor We have to make a simple request_ajax.php and put bellow some source code:

request_ajax.php

<?php
    
    $hostName = "localhost";
    $username = "root";
    $password = "jaydeepGondaliya";
    $dbname = "products";
 
    $mysqli = new mysqli($hostName, $username, $password, $dbname); 
    $sql = "SELECT * FROM products WHERE name LIKE '%".$_GET['name']."%'"; 
    $all_result = $mysqli->query($sql);
 
    $data_response = [];
    while($row = mysqli_fetch_assoc($all_result)){
       $data_response[] = array("id"=>$row['id'], "name"=>$row['name']);
    } 
    echo json_encode($data_response);
 
?>

Angular 6 CRUD Operations Application Tutorials

Read :

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about Chosen Ajax Autocomplete Textbox using jQuery, PHP and MySQL.
I would like to have feedback on my Pakainfo.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Dropzone php mysql Example with Demo 0

Simple Dropzone php mysql Example with Demo

Today, We want to share with you Dropzone php mysql Example with Demo.In this post we will show you Dropzone Multiple Image upload validation, hear for Laravel Dropzonejs Multiple File Upload using jQuery we will give you demo and example for implement.In this post, we will learn about DropzoneJS send additional data Multiple File Upload with an example.

Simple Dropzone php mysql Example with Demo

There are the Following The simple About Simple Dropzone php mysql Example with Demo Full Information With Example and source code.

As I will cover this Post with live Working example to develop filestack – DropZone Allowed File Extensions Tutorials, so the How to display existing files on server in Dropzone js using PHP for this example is following below.

Create Index.php File:

<!DOCTYPE html>
<html>
<head>
    <title>jQuery Ajax Dropzone display uploaded files on server PHP - Pakainfo.com</title>
    <script src="jquery/3.3.1/jquery.min.js"></script>
    <link href='dropzone/5.4.0/dropzone.css' type='text/css' rel='stylesheet'>
    <script src='dropzone/5.4.0/dropzone.js' type='text/javascript'></script>
    <style type="text/css">
      .dz-preview .dz-image img{
        width: 100% !important;
        height: 100% !important;
        object-fit: cover;
      }
    </style>
</head>
<body>
  
<div class="container pakainfo" >
  <h1>jQuery Ajax Dropzone display uploaded files on server in PHP <BR/> Pakainfo.com</h1>
  <div class='content'>
    <form action="do_multipleFilesUplodad.php" class="dropzone" >  
    </form> 
  </div> 
</div>
  
<script type="text/javascript">
  Dropzone.autoDiscover = false;
  $(".dropzone").dropzone({
    init: function() { 
      liveDropzone = this;
      $.ajax({
        url: 'do_multipleFilesUplodad.php',
        type: 'post',
        data: {request: 'get_request'},
        dataType: 'json',
        success: function(response){
  
          $.each(response, function(key,value) {
            var mockFile = { name: value.name, size: value.size};
  
            liveDropzone.emit("addedfile", mockFile);
            liveDropzone.emit("thumbnail", mockFile, value.path);
            liveDropzone.emit("complete", mockFile);
  
          });
  
        }
      });
    }
  });
</script>
  
</body>
</html>

Create Index.php File:

<?php
  
/* Upload PHP To directory Moves*/
$finalDirdata = "upload/";
  
$destination_path = "upload";
if(isset($_POST['request'])){
  $request = $_POST['request'];
}
  
/* Upload file */
if($destination_path == "upload"){
  $msg = "";
  if (move_uploaded_file($_FILES["file"]["tmp_name"], $finalDirdata.$_FILES['file']['name'])) {
    $msg = "Successfully uploaded";
  }else{ 
    $msg = "Error while uploading";
  }
  echo $msg;
  exit;
}
  
/* Read files from */
if($request == 'get_request'){
  $allFiles = [];
  
  $is_dir = $finalDirdata;
  if (is_dir($is_dir)){
    if ($dh = opendir($is_dir)){
      while (($file = readdir($dh)) !== false){
        if($file != '' && $file != '.' && $file != '..'){
          $file_path = $finalDirdata.$file;
          if(!is_dir($file_path)){
             $size = filesize($file_path);
             $allFiles[] = ['name'=>$file, 'size'=>$size, 'path'=>$file_path];
          }
        }
      }
      closedir($dh);
    }
  }
  
  echo json_encode($allFiles);
  exit;
}

Angular 6 CRUD Operations Application Tutorials

Read :

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about Simple Dropzone php mysql Example with Demo.
I would like to have feedback on my Pakainfo.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Vue js Toggle switch Update DB field using Ajax 0

Vue js Toggle switch Update DB field using Ajax

Today, We want to share with you Vue js Toggle switch Update DB field using Ajax.In this post we will show you Toggle Switches Laravel, Ajax and jQuery example, hear for Laravel Bootstrap Toggle switch Update DB field using Ajax
we will give you demo and example for implement.In this post, we will learn about Bootstrap Toggle Inside JQuery DataTable with an example.

Vue js Toggle switch Update DB field using Ajax

There are the Following The simple About Vue js Toggle switch Update DB field using Ajax Full Information With Example and source code.

As I will cover this Post with live Working example to develop Laravel 5.7 Toggle switch Update DB field using Ajax, so the Vue js Toggle Like Dislike Rating System using jQuery Ajax for this example is following below.

Step 1: Make a Vue JS App

In this step, I want to make vue cli app using bellow simple command:

vue create vueSwitch

Step 2: Install vue-js-toggle-button package

Now I want to install simple step by step vue-js-toggle-button npm package for vue js Bootstrap Toggle switch Update DB field using Ajax.

npm install vue-js-toggle-button --save

Step 3: Use vue-js-toggle-button

I want to use vue-js-toggle-button package in main.js file of vue js app.

src/main.js

import Vue from 'vue'
import App from './App.vue'
import ToggleButton from 'vue-js-toggle-button'
Vue.config.productionTip = false
Vue.use(ToggleButton)
new Vue({
  render: h => h(App),

}).$mount('#app')

Step 4: Update App.vue File

In this step, I want to update app.vue file, because i updated simple component therefor.

src/App.vue

<template>
  <div id="app">
    <Product></Product>
  </div>
</template>
<script>
import Product from './components/Product.vue'
export default {
  name: 'app',
  components: {
    Product
  }
}
</script>
[/php

<h3>Step 5: Create Product Component</h3>
<p>Here, we will create Product.vue component with following source code.</p>
<b>src/components/Product.vue</b>
[php]
<template>
  <div class="container pakainfo" style="text-align:center">
    <div class="large-12 medium-12 small-12 cell">
      <h1 style="font-family:arial">Vue js toggle button example - Infinityknow.com</h1>
  
        <toggle-button @change="onChangeEventHandler" :labels="{checked: 'On', unchecked: 'Off'}" style="margin-left: 20px" />
  
        <toggle-button :labels="{checked: 'Infinityknow.com', unchecked: 'pakainfo.com'}" width="250" style="margin-left: 20px" />
  
        <toggle-button :labels="{checked: 'Yes', unchecked: 'No'}" style="margin-left: 20px" />
  
    </div>
  </div>
</template>
<script>
  export default {
    data(){
      return {
        file: ''
      }
    },
  
    methods: {
      onChangeEventHandler(){
          alert('Welcome To Pakainfo.com Shop website');
      }
    }
  }
</script>

Last step, I can run vue js live app by using following simple below command:

npm run serve

Get more info for Toggle Switches Laravel, Ajax and vuejs example from here: https://www.npmjs.com/package/vue-js-toggle-button.

Angular 6 CRUD Operations Application Tutorials

Read :

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about Vue js Toggle switch Update DB field using Ajax.
I would like to have feedback on my Pakainfo.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

DataTables Checkbox Check All Example 0

DataTables Checkbox Check All Example

Today, We want to share with you DataTables Checkbox Check All Example.In this post we will show you datatables check if checkbox is checked, hear for jquery datatable checkbox header select all we will give you demo and example for implement.In this post, we will learn about select multiple rows with checkboxes using jquery datatable with an example.

DataTables Checkbox Check All Example

There are the Following The simple About DataTables Checkbox Check All Example Full Information With Example and source code.

As I will cover this Post with live Working example to develop jquery datatable multi select checkbox, so the datatables checkbox select all ajax for this example is following below.

Step 1: HTML Table

<table class="table table-striped" id="student_list">
 <thead><tr>
 <th><span class="hide"> - </span><div class="checkbox check_all_students_wrap">
<input type="checkbox" id="check_all_students" data-to-table="tasks"><label></label></div></th>
 <th>Student Name</th>
 <th>Online Status</th>
 <th>Options</th>
 </tr></thead>
 <tbody></tbody>
</table>

Step 2: Disable jQuery Sorting

$('#student_list').dataTable( {
        "columnDefs": [ {
          "targets": [0],
          "orderable": false,
    } ]
} );

And then, here is the source code to select all the checkbox using jQuery DataTable when table main header part to checkbox checked.

jQuery DataTable Checkbox Select All

$('body').on('change', '#check_all_students', function() {
   var stud_row, checked;
   stud_row = $('#student_list').find('tbody tr');
   checked = $(this).prop('checked');
   $.each(stud_row, function() {
      var checkbox = $($(this).find('td').eq(0)).find('input').prop('checked', checked);
   });
 });

Angular 6 CRUD Operations Application Tutorials

Read :

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about DataTables Checkbox Check All Example.
I would like to have feedback on my Pakainfo.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

DataTable Custom Filter Server Side Examples 0

DataTable Custom Filter Server Side

Today, We want to share with you DataTable Custom Filter Server Side.In this post we will show you Datatables custom filtering with server side, hear for Add Server-side DataTables Custom Filter using PHP with Ajax we will give you demo and example for implement.In this post, we will learn about Implement custom multicolumn server-side filtering in jQuery dataTables with an example.

DataTable Custom Filter Server Side

There are the Following The simple About DataTable Custom Filter Server Side Full Information With Example and source code.

As I will cover this Post with live Working example to develop Add custom Filter for server side Processing, so the Create Custom Dropdown Server Side Filter in Datatables for this example is following below.

HTML Table Source Code

<table class="list bordered highlight" id="MerchantCatalogs">
 <thead><tr> <th> <?php echo _("Reference"); ?> </th> <th> <?php echo _("Customer Name"); ?> </th> <th> <?php echo _("Invoice Date"); ?></th> <th> <?php echo _("Due Date"); ?></th> <th> <?php echo _("Amount"); ?> </th> <th> <?php echo _("Yet To Receive"); ?></th><th> <?php echo _("Status"); ?></th> </tr></thead>
 </table>

JS Source Code

ToReceiveTable = $("#MerchantCatalogs").dataTable({
 "processing": true,
 "serverSide": true,
 "order": [[ 6, "asc" ]],
 "pageLength": 50, 
 "ajax": "<?php echo get_url(); ?>ajax?MerchantCatalogs=yes"
 });

The Above one is ordinary ServerSide Processing DataTable code.

And then make a jQuery drop down within the datatable.

ToReceiveTable = $("#MerchantCatalogs").dataTable({
 "processing": true,
 "serverSide": true,
 "order": [[ 6, "asc" ]],
 "pageLength": 50,
 "dom": '<"ProductFilterCatalog">frtip',
 "ajax": "<?php echo get_url(); ?>ajax?MerchantCatalogs=yes"
 });
 $("div.ProductFilterCatalog").html('<label> Filter Status : <select name="ProductFilterCatalog" id="ProductFilterCatalog"> <option value="-1" > All </label>');

And then write the jQuery DataTable Refresh when member selects a filter option from the drop down which we Data added.

 $("#ProductFilterCatalog").on("change", function(){ 
    var FilterVal = $(this).val(); 
    var new_getURL = "<?php echo get_url(); ?>ajax?MerchantCatalogs=yes&FilterStatus="+FilterVal;
    ToReceiveTable.api().ajax.url(new_getURL).load();
 });

Now, we have to create a jQuery Ajax file to handle the request to server Side process.

if(isset($_GET['MerchantCatalogs']) && $_GET['MerchantCatalogs'] == 'yes'){
	
	$sql_details = array( 
		 'member' => 'kvcodes',
		 'pass' => '[email protected]',
		 'db'   => 'demo_db',
		 'host' => 'localhost'
		); 
	$table = 'customer_trans';
	$primaryKey = 'id';
	
	$columns = array(
		array( 'db' => '`so`.`friends_ref`',  'dt' => 0,	'field' => 'friends_ref' ),
		array( 'db' => '`debtor`.`name`',  	'dt' => 1,	'field' => 'name'),
		array( 'db' => '`so`.`display_dt`',	'dt' => 2,	'field' => 'display_dt','formatter' => function( $d, $row ) 	{ return date( 'jS M y', strtotime($d)); } ),
		array( 'db' => '`so`.`notify_dt`',   'dt' => 3,	'field' => 'notify_dt', 'formatter' => function( $d, $row ) 	{ return date( 'jS M y', strtotime($d)); } ),
		array( 'db' => '`so`.`product_amt`',  'dt' => 4,	'field' => 'product_amt'),
		array( 'db' => '`so`.`alloc`',  	'dt' => 5,	'field' => 'alloc'),
		array( 'db' => '`so`.`status`',   'dt' => 6,	'field' => 'status')
	);

	$joinQuery = "FROM `{$table}` AS `so`";  
	$additionalWhere = '';
	if(isset($_GET['FilterStatus'])){
			if($_GET['FilterStatus'] == 'Received'){
					$additionalWhere .= " AND status= 2 ";
			}elseif($_GET['FilterStatus'] == 'Overdue'){
					$additionalWhere .=" AND status = 1";
			}elseif($_GET['FilterStatus'] == 'Yet To Receive' ){
					$additionalWhere .=" AND status=3";
			}
	}
	
	$wigepa_sources = Master_Table::simple( $_GET, $sql_details, $table, $primaryKey, $columns, $joinQuery , $additionalWhere, '',  'yes' );
	echo json_encode($wigepa_sources);
}

CSS Part

.ProductFilterCatalog { float: left; text-align: left; }
.ProductFilterCatalog select { padding: 7px; border-color: #3d3d3d; }

Angular 6 CRUD Operations Application Tutorials

Read :

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about DataTable Custom Filter Server Side.
I would like to have feedback on my Pakainfo.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

JQuery Push Key And Value Into An Array 0

JQuery Push Key And Value Into An Array

Today, We want to share with you JQuery Push Key And Value Into An Array.In this post we will show you javascript array push key value pair dynamically, hear for how to push both key and value into an array in javascript we will give you demo and example for implement.In this post, we will learn about Push Both Key And Value Into An Array In JQuery with an example.

JQuery Push Key And Value Into An Array

There are the Following The simple About JQuery Push Key And Value Into An Array Full Information With Example and source code.

As I will cover this Post with live Working example to develop create array with key and value in jquery, so the javascript push object into array with key for this example is following below.

Push Both Key And Value Into An Array using JQuery

var teacher_details_arr = [{ index: 5, name: 'Jaydeep' },{ index: 2, name: 'Ankit' },{ index: 3, name: 'pakainfo'},{ index: 4, name: 'Krunal'}]; 

var student_details_arr = new Array();  // Empty here student_details_arr array for our use.

And then, I am going to simple copy this first jquery array values to second array , and then I am going to use simple javascript push method to source code copy pure js Index and name both simple things.

$.each(teacher_details_arr, function (index, value) {
      student_details_arr.push({name: value.name,  index:  value.index});
}); // Here I just exchange data the location of the main objects.

$.each(student_details_arr, function (index, value) {
    alert({"name: "+value.name +" and index: "+ value.index});
}); // Here I just exchange data the location of the simple objects.

From the above source code results like this simple result.

name: Jaydeep and index : 5

Angular 6 CRUD Operations Application Tutorials

Read :

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about JQuery Push Key And Value Into An Array.
I would like to have feedback on my Pakainfo.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

jQuery Ajax CRUD operations in Laravel 5.7 0

jQuery Ajax CRUD operations in Laravel 5.7

Today, We want to share with you jQuery Ajax CRUD operations in Laravel 5.7.In this post we will show you ajax crud operations in laravel 5.7 with modal & pagination, hear for Laravel 5.7 Ajax CRUD with Pagination example and demo from scratch we will give you demo and example for implement.In this post, we will learn about Laravel 5.7 Ajax CRUD example for web application without page refresh with an example.

jQuery Ajax CRUD operations in Laravel 5.7

There are the Following The simple About jQuery Ajax CRUD operations in Laravel 5.7 Full Information With Example and source code.

As I will cover this Post with live Working example to develop Ajax CRUD example in Laravel 5.7 application, so the laravel 5.7 ajax update database for this example is following below.

Step 1: Install Laravel 5.7

Run the below Laravel command to install laravel Latest version Like Laravel 5.7,

Composer create-project --prefer-dist laravel/laravel crud

Step 2: Setup MySQL Database Configuration

We can do all the database setup step by step configuration on .env file.

Step 3: Create Table

Comment to create table,

php artisan make:migration create_products_table --create=product

Now, Go to path “database/migrations” and here We can simple change the migration file of product table,

<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateproductsTable extends Migration
{
    public function up()
    {
        Schema::create('products', function(Blueprint $table)
        {
            $table->increments('id');
            $table->string('name');
            $table->string('description');
            $table->timestamps();
        });
    }
    public function down()
    {
        Schema::dropIfExists('products');
    }
}
 

After that we can Use the below PHP artisan command to migrate.

php artisan migrate

Step 4: Creating Laravel 5.7 Controller

Run the below simple command to create a Laravel controller as well as Laravel model,

php artisan make:controller ProductController --resource --model=Model/Product

We can display the created Laravel controller Path on “app/Http/Controllers/”

Step 5: Define a Laravel Routes

And then, We simple Run the following PHP artisan command to include the routes inside the file name web.php file of routes folder.

Route::resource('product','ProductController');

Step 6: Make a Laravel Default Methods In Product Controller

  • Index()
  • Create()
  • Store()
  • Show()
  • Edit()
  • Update()
  • Destroy()

Above All the Laravel methods are the default methods in ProductController

Step 7: Write The source Code For Laravel 5.7 CRUD Operation

And then We can display the All step by step process of CRUD operation in Laravel 5.7,

<?php
namespace App\Http\Controllers;
use App\Model\Product;
use Illuminate\Http\Request;
class ProductController extends Controller {
    public function index() {
        $products = Product::latest()->paginate(5);
        return view('products.index', compact('products'))->with('i', (request()->input('page', 1) - 1) * 5);
    }
    public function create() {
        return view('products.create');
    }
    public function store(Request $request) {
        $request->validate(['name' => 'required', 'description' => 'required', ]);
        Product::create($request->all());
        return redirect()->route('products.index')->with('success', 'product created successfully.');
    }
    public function show(Product $Product) {
        return view('products.show', compact('product'));
    }
    public function edit(Product $Product) {
        return view('products.edit', compact('product'));
    }
    public function update(Request $request, Product $Product) {
        $Product->validate(['name' => 'required', 'description' => 'required', ]);
        $product->update($request->all());
        return redirect()->route('products.index')->with('success', 'product updated successfully');
    }
    public function destroy(Product $Product) {
        $Product->delete();
        return redirect()->route('products.index')->with('success', 'product deleted successfully');
    }
}

Step 8: making a blade files In Laravel 5.7

We have Total 5 blade files,

  • Layout.blade.php
  • Index.blade.php
  • Create.blade.php
  • Edit.blade.php
  • Show.blade.php

Layout.blade.php

<!DOCTYPE html>
<html>
  <head>
    <title>Welcome To Pakainfo.com</title>
    <link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-alpha/css/bootstrap.css" rel="stylesheet">
  </head>
  <body>
    <div class="container">
      @yield('content')
    </div>
  </body>
</html>

Index.blade.php

@extends('product.layout')
@section('content')
<div class="row">
  <div class="col-lg-12 margin-tb">
    <div class="pull-left">
      <h2>Welcome
      </h2>
    </div>
    <div class="pull-right">
      <a class="btn btn-success" href="{{ route('products.create') }}"> Create New product
      </a>
    </div>
  </div>
</div>
@if ($message = Session::get('success'))
<div class="alert alert-success">
  <p>{{ $message }}
  </p>
</div>
@endif
<table class="table table-bordered">
  <tr>
    <th>Slno
    </th>
    <th>Name
    </th>
    <th>description
    </th>
    <th width="280px">Action
    </th>
  </tr>
  @foreach ($products as $product)
  <tr>
    <td>{{ ++$i }}
    </td>
    <td>{{ $product->name }}
    </td>
    <td>{{ $product->description }}
    </td>
    <td>
      <form action="{{ route('products.destroy',$product->id) }}" method="POST">
        <a class="btn btn-info" href="{{ route('products.show',$product->id) }}">Show
        </a>
        <a class="btn btn-success" href="{{ route('products.edit',$product->id) }}">Edit
        </a>
        @csrf
        @method('DELETE')
        <button type="submit" class="btn btn-danger">Delete
        </button>
      </form>
    </td>
  </tr>
  @endforeach
</table>
{!! $products->links() !!}
@endsection

Create.blade.php

@extends('products.layout')
@section('content')
<div class="row">
  <div class="col-lg-12 margin-tb">
    <div class="pull-left">
      <h2>Add New product
      </h2>
    </div>
    <div class="pull-right">
      <a class="btn btn-success" href="{{ route('products.index') }}"> Back
      </a>
    </div>
  </div>
</div>
@if ($errors->any())
<div class="alert alert-danger">
  <strong>Whoops!
  </strong> There were some problems with your input.
  <br>
  <br>
  <ul>
    @foreach ($errors->all() as $error)
    <li>{{ $error }}
    </li>
    @endforeach
  </ul>
</div>
@endif
<form action="{{ route('products.store') }}" method="POST">
  @csrf
  <div class="row">
    <div class="col-xs-12 col-sm-12 col-md-12">
      <div class="form-group">
        <strong>Name:
        </strong>
        <input type="text" name="name" class="form-control" placeholder="Name">
      </div>
    </div>
    <div class="col-xs-12 col-sm-12 col-md-12">
      <div class="form-group">
        <strong>Detail:
        </strong>
        <input type="text" name="description" class="form-control" placeholder="description">
      </div>
    </div>
    <div class="col-xs-12 col-sm-12 col-md-12 text-center">
      <button type="submit" class="btn btn-success">Submit
      </button>
    </div>
  </div>
</form>
@endsection

Edit.blade.php

@extends('products.layout')
@section('content')
<div class="row">
  <div class="col-lg-12 margin-tb">
    <div class="pull-left pakainfo">
      <h2>Edit product
      </h2>
    </div>
    <div class="pull-right pakainfo">
      <a class="btn btn-success" href="{{ route('products.index') }}"> Back
      </a>
    </div>
  </div>
</div>
@if ($errors->any())
<div class="alert alert-danger">
  <strong>Whoops!
  </strong> There were some More problems with your input.
  <br>
  <br>
  <ul>
    @foreach ($errors->all() as $error)
    <li>{{ $error }}
    </li>
    @endforeach
  </ul>
</div>
@endif
<form action="{{ route('products.update',$product->id) }}" method="POST">
  @csrf
  @method('PUT')
  <div class="row">
    <div class="col-xs-12 col-sm-12 col-md-12">
      <div class="form-group pakainfo">
        <strong>Name:
        </strong>
        <input type="text" name="name" value="{{ $product->name }}" class="form-control" placeholder="Name">
      </div>
    </div>
    <div class="col-xs-12 col-sm-12 col-md-12">
      <div class="form-group pakainfo">
        <strong>Detail:
        </strong>
        <input type="text" name="description" value="{{ $product->description }}" class="form-control" placeholder="description">
      </div>
    </div>
    <div class="col-xs-12 col-sm-12 col-md-12 text-center">
      <button type="submit" class="btn btn-success">Submit
      </button>
    </div>
  </div>
</form>
@endsection

Show.blade.php

@extends('products.layout')
@section('content')
<div class="row pakainfo">
  <div class="col-lg-12 margin-tb">
    <div class="pull-left">
      <h2> Show product
      </h2>
    </div>
    <div class="pull-right pakainfo">
      <a class="btn btn-success" href="{{ route('products.index') }}"> Back
      </a>
    </div>
  </div>
</div>
<div class="row">
  <div class="col-xs-12 col-sm-12 col-md-12">
    <div class="form-group pakainfo">
      <strong>Name:
      </strong>
      {{ $product->name }}
    </div>
  </div>
  <div class="col-xs-12 col-sm-12 col-md-12">
    <div class="form-group pakainfo">
      <strong>Details:
      </strong>
      {{ $product->description }}
    </div>
  </div>
</div>
@endsection

Last step You can Run the below php artisan command to run this project the local server

php artisan serve

Now We can display my local browsers server successfully running here http://localhost:8000/products

Angular 6 CRUD Operations Application Tutorials

Read :

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about jQuery Ajax CRUD operations in Laravel 5.7.
I would like to have feedback on my Pakainfo.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Bootstrap Toggle Inside JQuery DataTable 0

Bootstrap Toggle Inside JQuery DataTable

Today, We want to share with you Bootstrap Toggle Inside JQuery DataTable.In this post we will show you Bootstrap Switch / Toggle – examples, hear for bootstrap 4 toggle switch jQuery DataTables we will give you demo and example for implement.In this post, we will learn about How To Display Bootstrap Toggle Switch with DataTables via Render with an example.

Bootstrap Toggle Inside JQuery DataTable

There are the Following The simple About Bootstrap Toggle Inside JQuery DataTable Full Information With Example and source code.

Laravel Bootstrap Toggle switch Update DB field using Ajax

As I will cover this Post with live Working example to develop jQuery Datatable toggle filter, so the some major files and Directory structures for this example

Toggle Switches Laravel, Ajax and jQuery example

is following below.

DataTable Bootstrap Toggle

 <table id="saved-members-table" class="display responsive nowrap table table-striped table-bordered" width="100%" cellspacing="0">
<thead>
<tr><th><?php echo $global['client_name'];?></th> 
     <th><?php echo $global['phone'];?></th>
     <th>PC. No</th>
     <th>Membership Type</th>
     <th>Status</th>
 </tr>
</thead>
</table>

Laravel Toggle Switch Inside Bootstrap Ajax Example

HTML Part

<input id="live-toggle-example" type="checkbox" checked data-toggle="toggle" data-on="Active" data-off="Due" data-onstyle="success" data-offstyle="warning">

jQuery('#live-toggle-example').bootstrapToggle();

Laravel 5.7 Toggle switch Update DB field using Ajax

And then, the jQuery DataTable Server-side Processing JS source Code.

jQuery('#saved-members-table').DataTable({
    "processing": true,
    "serverSide": true,
    "ajax": "pakacodes.php?Members=yes", 
     "sScrollX": "100%", 
    aoColumns : [                          
        { "sWidth": "20%" },
        { "sWidth": "20%"},
        { "sWidth": "20%"},
        { "sWidth": "20%"},                           
        { "sWidth": "20%" }
    ],
"fnDrawCallback": function() {
    jQuery('#saved-members-table #live-toggle-example').bootstrapToggle();
}

Angular 6 CRUD Operations Application Tutorials

Read :

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about Bootstrap Toggle Inside JQuery DataTable.
I would like to have feedback on my Pakainfo.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

jQuery Regular Expression Real Time Form Validation Example 0

jQuery Regular Expression Real Time Form Validation Example

Today, We want to share with you jQuery Regular Expression Real Time Form Validation Example.In this post we will show you Jquery Validation with Regular Expressions, hear for password validation in jquery using regular expression we will give you demo and example for implement.In this post, we will learn about Real Time Form Validation using Regular Expressions in jQuery with an example.

jQuery Regular Expression Real Time Form Validation Example

There are the Following The simple About jQuery Regular Expression Real Time Form Validation Example Full Information With Example and source code.

As I will cover this Post with live Working example to develop jquery regular expression validation for special characters, so the some major files and Directory structures for this example is following below.

  • Email
  • URL
  • Username
  • Password
  • Strong Password

Email validation in jquery using regular expression

Email Checking using Regular Expression

Regular Expression with jQuery Validation

function checkLiveEmail(email)
{
    //jQuery Regular Expression Real Time Form Validation Example
    var liveStrongPtrn = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i);
    if(liveStrongPtrn.test(email)){
        return true;
    } else {
        return false;
    }
}

simple JavaScript regular expression for email validation
var liveStrongPtrn = /^[a-zA-Z0-9._-][email protected][a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;

Output – Results
admin.email.com = Error
[email protected] = Ok

URL validation in jquery using regular expression

URL Check using Regular Expression

http or https with URL

function checkUrl(url)
{
    //regular url expression for URL
    var liveStrongPtrn = /^(http|https)?:\/\/[a-zA-Z0-9-\.]+\.[a-z]{2,4}/;
 
    if(liveStrongPtrn.test(url)){
        return true;
    } else {
        return false;
    }
}

Output – Results
www.pakainfo.com = Error
https://pakainfo.com = Ok
https://www.pakainfo.com = Ok

Username validation in jquery using regular expression

Username Check using Regular Expression

accept 5-15 characters without any symbol or special characters

function checkLiveFirstname(username){
    var liveStrongPtrn = /^[a-z0-9_-]{5,15}$/;
    if(liveStrongPtrn.test(username)){
        return true;
    }else{
        return false;
    }
}

Output – Results
Result:
jaydeep.gondaliya = Error
jaydeep123 = Ok

password validation in jquery using regular expression

Password using Regular Expression

accept 6-18 lowercase, uppercase, characters, numbers

function checkPassword(password){
    var liveStrongPtrn = /^[a-zA-Z0-9_-]{6,18}$/;
    if(liveStrongPtrn.test(password)){
        return true;
    }else{
        return false;
    }
}

Output – Results
Result:
JdPaka = Ok
[email protected] = Error

Strong Password using Regular Expression

  • Must be at least 8 characters
  • At least 1 number, 1 lowercase, 1 uppercase letter
  • At least 1 special character from @#$%&

var liveStrongPtrn = /^.*(?=.{8,})(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[@#$%&]).*$/;

Output – Results
Result:
[email protected] = Ok
[email protected] = Error

jQuery Regular Expression Real Time Form Validation Example – Outout

Regular-Expression-With-jQuery-Validation

Regular-Expression-With-jQuery-Validation

Angular 6 CRUD Operations Application Tutorials

Read :

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about jQuery Regular Expression Real Time Form Validation Example.
I would like to have feedback on my Pakainfo.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Laravel 5.7 Jquery Ajax CRUD(insert update delete) 0

Laravel 5.7 Jquery Ajax CRUD(insert update delete)

Today, We want to share with you Laravel 5.7 Jquery Ajax CRUD(insert update delete).In this post we will show you Ajax CRUD example in Laravel 5.7 application, hear for Laravel 5.7 CRUD (Create Read Update Delete) Example from scratch we will give you demo and example for implement.In this post, we will learn about Laravel 5.7 CRUD Insert Update Delete using Jquery Ajax Tutorial example with source code with an example.

Laravel 5.7 Jquery Ajax CRUD(insert update delete)

There are the Following The simple About Laravel 5.7 Jquery Ajax CRUD(insert update delete) Full Information With Example and source code.

As I will cover this Post with live Working example to develop Laravel 5.7 CRUD (Create Read Update Delete) Tutorial Example, so the Simple Laravel 5.7 Jquery Ajax CRUD(insert update delete) tutorial example with source code for this example is following below.

Step : 1 Create articles Table Migration

Laravel Table Migration

php artisan make:migration create_Articles_table

After run this commandd open articles table mimgration file and add foollowing code. migration file create automatic in database/migrations/ this location.

database/migrations/

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateArticlesTable extends Migration
{
    public function up()
    {
        Schema::create('articles', function (Blueprint $table) {
            $table->increments('id');
            $table->string('title');
            $table->text('article_content');
            $table->timestamps();
        });
    }

    public function down()
    {
        Schema::dropIfExists('articles');
    }
}

And then, Laravel CMD to run following command for run migration.

php artisan migrate

Step : 2 Create articles Table Model

After that, create Article table model usign by following command.

php artisan make:demo Article

And then, open app/Article.php file and past into it following source code.

app/Article.php

namespace App;
use Illuminate\Database\Eloquent\Model;
class Article extends Model
{
    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */

    protected $fillable = [
        'title', 'article_content'
    ];
}

Step : 3 Create Laravel Routes

Next, create following routes in routes/web.php file.

routes/web.php

Route::get('web-articles', '[email protected]');
Route::resource('articles','ArticleController');

Step : 4 Make Laravel 5.7 Controller

And then, we need to create ArticleController.php file in app/Http/Controllers/ this path and put into it following source code.

app/Http/Controllers/ArticleController.php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Article;

class ArticleController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function webArticles()
    {
        return view('web-articles');
    }

    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        $articles = Article::latest()->paginate(5);
        return response()->json($articles);
    }

    /**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function store(Request $request)
    {
        $Article = Article::create($request->all());
        return response()->json($Article);
    }

    /**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function update(Request $request, $id)
    {
        $Article = Article::find($id)->update($request->all());
        return response()->json($Article);
    }

    /**
     * Remove the specified resource from storage.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function destroy($id)
    {
        Article::find($id)->delete();
        return response()->json(['done']);
    }
}

Step : 5 Create Laravel Blade/View File

Now, we will make a web-articles.blade.php file in resources/views/ folder. and then simply put into it following source code. here We are using simple bootstrap layout but you can set accourding to you.

resources/views/web-articles.blade.php

<!DOCTYPE html>
<html>
<head>
  <title>Laravel 5.7 Ajax CRUD Example</title>
  <meta name="csrf-token" content="{{ csrf_token() }}">
  <link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-alpha/css/bootstrap.css">
</head>
<body>
  <div class="container">
    <div class="row">
        <div class="col-lg-12 margin-tb">
            <div class="pull-left">
                <h2>Laravel 5.7 Ajax CRUD Example Demo</h2>
            </div>
            <div class="pull-right">
        <button type="button" class="btn btn-success" data-toggle="modal" data-target="#create-data-component">Create New Article</button>
            </div>
        </div>
    </div>
    <table class="table table-bordered">
      <thead>
          <tr>
        <th>Title</th>
        <th>article_content</th>
        <th width="200px">Action</th>
          </tr>
      </thead>
      <tbody>
      </tbody>
    </table>

    <ul id="pagination" class="pagination-sm"></ul>

    <!-- Create data-component Modal -->
    @include('create')
    <!-- Edit data-component Modal -->
    @include('edit')
  </div>
  <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.0/jquery.js"></script>
  <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-alpha/js/bootstrap.min.js"></script>
  <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/twbs-pagination/1.3.1/jquery.twbsPagination.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/1000hz-bootstrap-validator/0.11.5/validator.min.js"></script>
  <script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/js/toastr.min.js"></script>
  <link href="//cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/css/toastr.min.css" rel="stylesheet">

  <script type="text/javascript">
    var url = "<?php echo route('articles.index')?>";
  </script>
  <script src="/js/ArticlesAjax.js"></script> 
</body>
</html>

Step : 6 Create JS File

Next, we need to create ArticlesAjax.js JS file in public/js/ path and put into it following source code.

public/js/ArticlesAjax.js

var page = 1;
var active_page = 1;
var total_page = 0;
var ajax_data_call = 0;

manageData();

/* manage data list */
function manageData() {
    $.ajax({
        dataType: 'json',
        url: url,
        data: {page:page}
    }).done(function(data) {
      total_page = data.last_page;
      active_page = data.active_page;
      $('#pagination').twbsPagination({
          totalPages: total_page,
          visiblePages: active_page,
          onPageClick: function (event, pageL) {
            page = pageL;
                if(ajax_data_call != 0){
              fetchAllData();
                }
          }
      });
      handleDatalines(data.data);
        ajax_data_call = 1;
    });
}

$.ajaxSetup({
    headers: {
        'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
    }
});

/* Get Page Data*/
function fetchAllData() {
  $.ajax({
      dataType: 'json',
      url: url,
      data: {page:page}
  }).done(function(data) {
    handleDatalines(data.data);
  });
}

/* Add new Article table row */
function handleDatalines(data) {
  var data_lines = '';
  $.each( data, function( key, value ) {
      data_lines = data_lines + '<tr>';
      data_lines = data_lines + '<td>'+value.title+'</td>';
      data_lines = data_lines + '<td>'+value.article_content+'</td>';
      data_lines = data_lines + '<td data-id="'+value.id+'">';
        data_lines = data_lines + '<button data-toggle="modal" data-target="#edit-data-component" class="btn btn-primary edit-data-component">Edit</button> ';
        data_lines = data_lines + '<button class="btn btn-danger remove-data-component">Delete</button>';
        data_lines = data_lines + '</td>';
      data_lines = data_lines + '</tr>';
  });
  $("tbody").html(data_lines);
}

/* Create new Article */
$(".crud-submit").click(function(e) {
    e.preventDefault();
    var actions_crud = $("#create-data-component").find("form").attr("action");
    var title = $("#create-data-component").find("input[name='title']").val();
    var article_content = $("#create-data-component").find("textarea[name='article_content']").val();
    $.ajax({
        dataType: 'json',
        type:'Article',
        url: actions_crud,
        data:{title:title, article_content:article_content}
    }).done(function(data){
        fetchAllData();
        $(".modal").modal('hide');
        toastr.success('Article Created Successfully.', 'Success Alert', {timeOut: 5000});
    });
});

/* Remove Article */
$("body").on("click",".remove-data-component",function() {
    var id = $(this).parent("td").data('id');
    var c_obj = $(this).parents("tr");
    $.ajax({
        dataType: 'json',
        type:'delete',
        url: url + '/' + id,
    }).done(function(data) {
        c_obj.remove();
        toastr.success('Article Deleted Successfully.', 'Success Alert', {timeOut: 5000});
        fetchAllData();
    });
});

/* Edit Article */
$("body").on("click",".edit-data-component",function() {
    var id = $(this).parent("td").data('id');
    var title = $(this).parent("td").prev("td").prev("td").text();
    var article_content = $(this).parent("td").prev("td").text();
    $("#edit-data-component").find("input[name='title']").val(title);
    $("#edit-data-component").find("textarea[name='article_content']").val(article_content);
    $("#edit-data-component").find("form").attr("action",url + '/' + id);
});

/* Updated new Article */
$(".crud-submit-edit").click(function(e) {
    e.preventDefault();
    var actions_crud = $("#edit-data-component").find("form").attr("action");
    var title = $("#edit-data-component").find("input[name='title']").val();
    var article_content = $("#edit-data-component").find("textarea[name='article_content']").val();
    $.ajax({
        dataType: 'json',
        type:'PUT',
        url: actions_crud,
        data:{title:title, article_content:article_content}
    }).done(function(data){
        fetchAllData();
        $(".modal").modal('hide');
        toastr.success('Article Updated Successfully.', 'Success Alert', {timeOut: 5000});
    });
}); 

Last I am ready to Laravel Project run our example Therefor run bellow command ro quick run:

Laravel 5.7 run our example

php artisan serve

Finnally Step We can open bellow simple URL on your Browsers run:

http://localhost:8000/web-articles

Angular 6 CRUD Operations Application Tutorials

Read :

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about Laravel 5.7 Jquery Ajax CRUD(insert update delete).
I would like to have feedback on my Pakainfo.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.