Today, We want to share with you PHP Toggle switch Update DB field using jQuery Ajax.
In this post we will show you Bootstrap Switch using PHP and MySQL, hear for store value from on/off button in mysql database using php ajax we will give you demo and example for implement.In this post, we will learn about PHP Ajax Update MySQL Data Through Bootstrap Modal with an example.
PHP Toggle switch Update DB field using jQuery Ajax
There are the Following The simple About PHP Toggle switch Update DB field using jQuery Ajax Full Information With Example and source code.
As I will cover this Post with live Working example to develop Create Radio Button Toggle Switch with Bootstrap, jQuery & PHP, so the some major files and Directory structures for this example is following below.
- index.php
- radio_toggle.js
- save.php
- style.css
Steps 1: Make HTML Form with Radio Button
index.php
This is where I will make a simple HTML form and PHP server side source code for our web application. To make the forms simply all souce code copy and write it into your any text editor Like Notepad++, then save file it as index.php.
E-junkie: Sell digital downloads online
E-junkie Provides a Copy-paste buy-now, and cart buttons for selling downloads, codes and tangible products on any website, blog, social media, email and messenger!
Also see:
<div class="row infinity"> <form method="post" action="save.php"> <div class="form-group infinity"> <label for="results" class="infinity col-sm-4 col-md-4 control-label text-right">Results: </label> <div class="infinity col-sm-7 col-md-7"> <div class="input-group"> <div id="status_radio" class="btn-group"> <a class="btn btn-success btn-sm active">Pass</a> <a class="btn btn-success btn-sm inCurrent">Fail</a> </div> </div> </div> </div> <div class="form-group"> <label for="confirm" class="col-sm-4 col-md-4 infinity control-label text-right">Are you confirm this ?</label> <div class="col-sm-7 col-md-7"> <div class="input-group"> <div id="check_radio" class="btn-group"> <a class="btn btn-success btn-sm active">YES</a> <a class="btn btn-success btn-sm inCurrent">I don't know</a> <a class="btn btn-success btn-sm inCurrent">NO</a> </div> </div> <button type="submit" class="btn btn-success" name="btn-save" id="btn-submit"> Submit </button> </div> </div> </form> </div>
Steps 2: Make custom CSS style
create custom CSS style.css file and make class inCurrent
.inCurrent{ color: #c6000; background-color: #3d3d3d; }
Steps 3: Manage Radio Button Toggle
radio_toggle.js
$(document).ready(function(){ $("#status_radio a, #check_radio a").on('click', function(){ var checked = $(this).data('title'); var toggle = $(this).data('toggle'); $('#'+toggle).prop('value', checked); $('a[data-toggle="'+toggle+'"]').not('[data-title="'+checked+'"]').removeClass('active').addClass('inCurrent'); $('a[data-toggle="'+toggle+'"][data-title="'+checked+'"]').removeClass('inCurrent').addClass('active'); }) });
Steps 4: Manage Form Submit POST Values
save.php
jQuery 15 Powerful Tips and Tricks for Developers and Web Designer
Read :
Summary
You can also read about AngularJS, ASP.NET, VueJs, PHP.
I hope you get an idea about bootstrap toggle switch update db field using ajax,.
I would like to have feedback on my Infinityknow.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.