article

Showing posts with label web-development (jquery). Show all posts
Showing posts with label web-development (jquery). Show all posts

Saturday, February 13, 2021

Live voting System using PHP Mysql and jquery Ajax bootstrap progressbar

Live voting System using PHP Mysql and jquery Ajax bootstrap progressbar

--
-- Table structure for table `tblprogramming`
--

CREATE TABLE `tblprogramming` (
  `id` int(11) NOT NULL,
  `title` varchar(250) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

--
-- Dumping data for table `tblprogramming`
--

INSERT INTO `tblprogramming` (`id`, `title`) VALUES
(1, 'Flask'),
(2, 'Laravel'),
(3, 'React.js'),
(4, 'Express'),
(5, 'Django');

--
-- Indexes for dumped tables
--

--
-- Indexes for table `tblprogramming`
--
ALTER TABLE `tblprogramming`
  ADD PRIMARY KEY (`id`);

--
-- AUTO_INCREMENT for dumped tables
--

--
-- AUTO_INCREMENT for table `tblprogramming`
--
ALTER TABLE `tblprogramming`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6;

--
-- Table structure for table `tbl_poll`
--

CREATE TABLE `tbl_poll` (
  `poll_id` int(11) NOT NULL,
  `web_framework` varchar(100) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `tbl_poll`
--

INSERT INTO `tbl_poll` (`poll_id`, `web_framework`) VALUES
(8, 'Flask'),
(9, 'Flask'),
(10, 'Flask'),
(11, 'Express'),
(12, 'React.js'),
(13, 'Laravel'),
(14, 'Flask'),
(15, 'Flask'),
(16, 'Laravel'),
(17, 'Django'),
(18, 'Django'),
(19, 'Flask');

--
-- Indexes for dumped tables
--

--
-- Indexes for table `tbl_poll`
--
ALTER TABLE `tbl_poll`
  ADD PRIMARY KEY (`poll_id`);

--
-- AUTO_INCREMENT for dumped tables
--

--
-- AUTO_INCREMENT for table `tbl_poll`
--
ALTER TABLE `tbl_poll`
  MODIFY `poll_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=20;
index.php
//index.php
<html>  
<head>  
<title>Live voting System using PHP Mysql and jquery Ajax bootstrap progressbar</title>
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>	
</head>  
<body>  
<div class="container">  
<?php
 include('dbcon.php');
 $query = $conn->query("SELECT * FROM tblprogramming order by id asc");
?>
            <br />  
            <br />
			<br />
			<h2 align="center">Live voting System using PHP Mysql and jquery Ajax bootstrap progressbar</h2><br />
			<div class="row">
				<div class="col-md-6">
					<form method="post" id="poll_form">
						<h3>Which is Best Web Development Frameworks</h3>
						<br />
						<?php  while ($row = $query ->fetch_object()) { ?>
						<div class="radio">
							<label><h4><input type="radio" name="poll_option" class="poll_option" value="<?php echo $row->title; ?>" /> <?php echo $row->title; ?></h4></label>
						</div>
						<?php } ?>
						<br />
						<input type="submit" name="poll_button" id="poll_button" class="btn btn-primary" />
					</form>
					<br />
				</div>
				<div class="col-md-6">
					<br />
					<br />
					<br />
					<h4>Live Poll Result</h4><br />
					<div id="poll_result"></div>
				</div>
			</div>
			<br />
			<br />
			<br />
		</div>
<script>  
$(document).ready(function(){
	fetch_poll_data();
	function fetch_poll_data()
	{
		$.ajax({
			url:"polldata.php",
			method:"POST",
			success:function(data)
			{
				$('#poll_result').html(data);
			}
		});
	}
	$('#poll_form').on('submit', function(event){
		event.preventDefault();
		var poll_option = '';
		$('.poll_option').each(function(){
			if($(this).prop("checked"))
			{
				poll_option = $(this).val();
			}
		});
		if(poll_option != '')
		{
			$('#poll_button').attr('disabled', 'disabled');
			var form_data = $(this).serialize();
			$.ajax({
				url:"insert.php",
				method:"POST",
				data:form_data,
				success:function()
				{
					$('#poll_form')[0].reset();
					$('#poll_button').attr('disabled', false);
					fetch_poll_data();
					alert("Poll Submitted Successfully");
				}
			});
		}
		else
		{
			alert("Please Select Option");
		}
	});
});  
</script>
</body>  
</html>  
polldata.php
//polldata.php
<?php
include('dbcon.php');
$resulttotal = $conn->query("SELECT * FROM tbl_poll"); 
$total_poll_row = mysqli_num_rows($resulttotal);

$query = $conn->query("SELECT * FROM tblprogramming order by id asc");
$output = '';
while ($row = $query ->fetch_object()) {
		$title=$row->title; 
		$result = $conn->query("SELECT * FROM tbl_poll WHERE web_framework = '".$title."'"); 
		$row = $result->fetch_row();
		$total_row = mysqli_num_rows($result);
		$percentage_vote = round(($total_row/$total_poll_row)*100);
		$progress_bar_class = '';
		if($percentage_vote >= 40)
		{
			$progress_bar_class = 'progress-bar-success';
		}
		else if($percentage_vote >= 25 && $percentage_vote < 40)
		{
			$progress_bar_class = 'progress-bar-info';
		}
		else if($percentage_vote >= 10 && $percentage_vote < 25)
		{
			$progress_bar_class = 'progress-bar-warning';
		}
		else
		{
			$progress_bar_class = 'progress-bar-danger';
		}
		$output .= '
		<div class="row">
			<div class="col-md-2" align="right">
				<label>'.$title.'</label>
			</div>
			<div class="col-md-10">
				<div class="progress">
					<div class="progress-bar '.$progress_bar_class.'" role="progressbar" aria-valuenow="'.$percentage_vote.'" aria-valuemin="0" aria-valuemax="100" style="width:'.$percentage_vote.'%">
						'.$percentage_vote.' % programmer like <b>'.$title.'</b> PHP Framework
					</div>
				</div>
			</div>
		</div>
		
		';
}
echo $output;
?>
insert.php
//insert.php
<?php
include('dbcon.php');
if(isset($_POST["poll_option"]))
{
	$poll_option = $_POST["poll_option"];
    $sql = "INSERT INTO tbl_poll(web_framework) VALUES ('$poll_option')"; 
    $conn->query($sql);
}
?>
dbcon.php
//dbcon.php
<?php
$conn = new mysqli('localhost','root','','testingdb');
if ($conn->connect_error) {
    die('Error : ('. $conn->connect_errno .') '. $conn->connect_error);
}
?>

Friday, February 12, 2021

PHP Mysql Image Crop & Upload using JQuery Ajax

PHP Mysql Image Crop & Upload using JQuery Ajax

Croppie
Croppie is a fast, easy to use image cropping plugin with tons of configuration options!


--
-- Table structure for table `uploads`
--

CREATE TABLE `uploads` (
  `id` int(11) NOT NULL,
  `file_name` varchar(150) NOT NULL,
  `upload_time` datetime NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `uploads`
--

INSERT INTO `uploads` (`id`, `file_name`, `upload_time`) VALUES
(1, '1613121943.jpg', '2021-02-12 10:25:43');

--
-- Indexes for dumped tables
--

--
-- Indexes for table `uploads`
--
ALTER TABLE `uploads`
  ADD PRIMARY KEY (`id`);

--
-- AUTO_INCREMENT for dumped tables
--

--
-- AUTO_INCREMENT for table `uploads`
--
ALTER TABLE `uploads`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;


index.php
//index.php
<!DOCTYPE html>
<html>
 <head>
  <title>PHP Mysql Image Crop & Upload using JQuery Ajax</title>
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/croppie/2.6.5/croppie.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/croppie/2.6.5/croppie.min.css" />
</head>
<body>  
        <div class="container">
          <br /> 
      <h3 align="center">PHP Mysql Image Crop & Upload using JQuery Ajax</h3>
      <br />
      <br />
   <div class="panel panel-default">
      <div class="panel-heading">Select Profile Image</div>
      <div class="panel-body" align="center">
       <input type="file" name="upload_image" id="upload_image" accept="image/*" />
       <br />
       <div id="uploaded_image"></div>
      </div>
     </div>
    </div>

<div id="uploadimageModal" class="modal" role="dialog">
 <div class="modal-dialog">
  <div class="modal-content">
        <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal">×</button>
          <h4 class="modal-title">Upload & Crop Image</h4>
        </div>
        <div class="modal-body">
          <div class="row">
       <div class="col-md-8 text-center">
        <div id="image_demo" style="width:350px; margin-top:30px"></div>
       </div>
       <div class="col-md-4" style="padding-top:30px;">
        <br />
        <br />
        <br/>
        <button class="btn btn-success crop_image">Crop & Upload Image</button>
     </div>
    </div>
        </div>
        <div class="modal-footer">
          <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
        </div>
     </div>
    </div>
</div>

<script>  
$(document).ready(function(){

 $image_crop = $('#image_demo').croppie({
    enableExif: true,
    viewport: {
      width:200,
      height:200,
      type:'square' //circle
    },
    boundary:{
      width:300,
      height:300
    }
  });

  $('#upload_image').on('change', function(){
    var reader = new FileReader();
    reader.onload = function (event) {
      $image_crop.croppie('bind', {
        url: event.target.result
      }).then(function(){
        console.log('jQuery bind complete');
      });
    }
    reader.readAsDataURL(this.files[0]);
    $('#uploadimageModal').modal('show');
  });

  $('.crop_image').click(function(event){
    $image_crop.croppie('result', {
      type: 'canvas',
      size: 'viewport'
    }).then(function(response){
      $.ajax({
        url:"upload.php",
        type: "POST",
        data:{"image": response},
        success:function(data)
        {
          $('#uploadimageModal').modal('hide');
          $('#uploaded_image').html(data);
        }
      });
    })
  });

});  
</script>
 </body>
</html>
upload.php
<?php
//upload.php
include('dbcon.php');
if(isset($_POST["image"]))
{
 $data = $_POST["image"];
 $img_array_1 = explode(";", $data);
 $img_array_2 = explode(",", $img_array_1[1]);
 $basedecode = base64_decode($img_array_2[1]);
 $filename = time() . '.jpg';
 file_put_contents("upload/$filename", $basedecode);
 //file_put_contents($filename, $basedecode);
 echo '<img src="'.$filename.'" class="img-thumbnail" />';
 $now = date("Y-m-d H:i:s");
 $sql = "INSERT INTO uploads(file_name, upload_time) VALUES ('$filename','$now')"; 
 $conn->query($sql); 
}
?>
//dbcon.php
<?php
$conn = new mysqli('localhost','root','','testingdb');
if ($conn->connect_error) {
    die('Error : ('. $conn->connect_errno .') '. $conn->connect_error);
}
?>

Wednesday, February 3, 2021

Insert Bootstrap Tokenfield Tag Data using PHP Mysql and Jquery Ajax

Insert Bootstrap Tokenfield Tag Data using PHP Mysql and Jquery Ajax

--
-- Table structure for table `skills`
--

CREATE TABLE `skills` (
  `id` int(11) NOT NULL,
  `skillname` varchar(150) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `skills`
--

INSERT INTO `skills` (`id`, `skillname`) VALUES
(2, 'Python Flask'),
(3, 'Laravel'),
(4, 'Python Django'),
(5, 'Angular'),
(6, 'PHP'),
(7, 'Codeigniter'),
(8, 'Python TKinter'),
(9, 'JQuery'),
(10, 'Javascript'),
(11, 'CakePHP'),
(12, 'Mysql'),
(13, 'MongoDB'),
(14, 'Java'),
(15, 'Android Studio'),
(16, 'Bootstrap'),
(17, 'Java Swing'),
(18, 'NodeJS'),
(19, 'NodeJS Express');

--
-- Indexes for dumped tables
--

--
-- Indexes for table `skills`
--
ALTER TABLE `skills`
  ADD PRIMARY KEY (`id`);

--
-- AUTO_INCREMENT for dumped tables
--

--
-- AUTO_INCREMENT for table `skills`
--
ALTER TABLE `skills`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=20;
--
-- Table structure for table `user`
--

CREATE TABLE `user` (
  `id` int(11) NOT NULL,
  `fullname` varchar(150) NOT NULL,
  `skills` varchar(150) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `user`
--

INSERT INTO `user` (`id`, `fullname`, `skills`) VALUES
(1, 'Michael00000', 'Holz0000'),
(2, 'Paula', 'Wilson'),
(3, 'Antonio11111', 'Moreno11111'),
(4, 'cairocoders', 'NodeJS, NodeJS Express, CakePHP, Python Django');

--
-- Indexes for dumped tables
--

--
-- Indexes for table `user`
--
ALTER TABLE `user`
  ADD PRIMARY KEY (`id`);

--
-- AUTO_INCREMENT for dumped tables
--

--
-- AUTO_INCREMENT for table `user`
--
ALTER TABLE `user`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=1;

JqueryUI Autocomplete : https://jqueryui.com/autocomplete/
Bootstrap Tokenfield : https://sliptree.github.io/bootstrap-tokenfield/
index.php
//index.php
<!DOCTYPE html>
<html>
 <head>
  <title>Insert Bootstrap Tokenfield Tag Data using PHP Mysql and Jquery Ajax</title>
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>

<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.css">
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-tokenfield/0.12.0/css/bootstrap-tokenfield.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-tokenfield/0.12.0/bootstrap-tokenfield.js"></script>
</head>
 <body>
  <br />
  <div class="container">
   <div class="row">
    <h2 align="center">Insert Bootstrap Tokenfield Tag Data using PHP Mysql and Jquery Ajax</h2>
    <div class="col-md-6" style="margin:0 auto; float:none;">
      <p id="success_message"></p>
      <form method="post" id="reg_form">
       <div class="form-group">
        <label>Enter Name</label>
        <input type="text" name="name" id="name" class="form-control" />
       </div>
       <div class="form-group">
        <label>Enter your Skill</label>
        <input type="text" name="skill" id="skill" class="form-control" />
       </div>
       <div class="form-group">
        <input type="submit" name="submit" id="submit" class="btn btn-info" value="Submit" />
       </div>
      </form>
     </div>
    </div>
  </div> 
<?php
 include('dbcon.php');
$result = $conn->query("SELECT * FROM skills");
$result->fetch_all(MYSQLI_ASSOC);
?>
  <script>
    $(document).ready(function(){
      $('#skill').tokenfield({
        autocomplete:{
        source: [<?php foreach($result as $row) { ?>
			"<?php echo $row['skillname']; ?>", 
			<?php } ?>],
        delay:100
        },
        showAutocompleteOnFocus: true
      });
     
      $('#reg_form').on('submit', function(event){
        event.preventDefault();
        if($.trim($('#name').val()).length == 0) {
          alert("Please Enter Your Name");
          return false;
        }else if($.trim($('#skill').val()).length == 0) {
          alert("Please Enter Atleast one Skill");
          return false;
        }else{
          var form_data = $(this).serialize();
          $('#submit').attr("disabled","disabled");
          $.ajax({
              url:"insert.php",
              method:"POST",
              data:form_data,
              beforeSend:function(){
              $('#submit').val('Submitting...');
              },
              success:function(data){
                if(data != '') {
                  $('#name').val('');
                  $('#skill').tokenfield('setTokens',[]);
                  $('#success_message').html(data);
                  $('#submit').attr("disabled", false);
                  $('#submit').val('Submit');
                }
              }
          });
          setInterval(function(){
            $('#success_message').html('');
          }, 5000);
        }
      });
});
</script>     
</body>
</html>
insert.php
//insert.php
<?php
include('dbcon.php');
if(isset($_POST["name"]))
{
	$fullname = $_POST["name"];
	$skills = $_POST["skill"];
	$sql = "INSERT INTO user(fullname,skills) VALUES ('$fullname','$skills')"; 
    $insert = $conn->query($sql);
	$output = '
	  <div class="alert alert-success">
	   Your data has been successfully saved 
	  </div>
	  ';
	echo $output;
}
?>

Tuesday, February 2, 2021

PHP Mysqli Multiple Select option using Bootstrap Select Plugin and Jquery Ajax

PHP Mysqli Multiple Select option using Bootstrap Select Plugin and Jquery Ajax

--
-- Table structure for table `skills`
--

CREATE TABLE `skills` (
  `id` int(11) NOT NULL,
  `skillname` varchar(150) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Indexes for dumped tables
--

--
-- Indexes for table `skills`
--
ALTER TABLE `skills`
  ADD PRIMARY KEY (`id`);

--
-- AUTO_INCREMENT for dumped tables
--

--
-- AUTO_INCREMENT for table `skills`
--
ALTER TABLE `skills`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=1;

bootstrap select https://developer.snapappointments.com/bootstrap-select/examples/
//index.html
<!DOCTYPE html>
<html>
 <head>
  <title>PHP Mysqli Multiple Select option using Bootstrap Select Plugin and Jquery Ajax</title>
  <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
  <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.12.2/css/bootstrap-select.min.css">
  <script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.12.2/js/bootstrap-select.min.js"></script>
 </head>
 <body>
  <br /><br />
  <div class="container">
   <br />
   <h2 align="center">PHP Mysqli Multiple Select option using Bootstrap Select Plugin and Jquery Ajax</h2>
   <br />
   <div class="col-md-4" style="margin-left:200px;">
    <form method="post" id="multiple_select_form">
     <select name="skills" id="skills" class="form-control selectpicker" data-live-search="true" multiple>
      <option value="Python Flask">Python Flask</option>
      <option value="Python Django">Python Django</option>
      <option value="Express.js">Express.js</option>
      <option value="Laravel">Laravel</option>
      <option value="Spring">Spring</option>
      <option value="Angular">Angular</option>
      <option value="React">React</option>
     </select>
     <br /><br />
     <input type="hidden" name="hidden_skills" id="hidden_skills" />
     <input type="submit" name="submit" class="btn btn-info" value="Submit" />
    </form>
    <br />
   </div>
  </div>
  <script>
    $(document).ready(function(){
     $('.selectpicker').selectpicker();
    
     $('#skills').change(function(){
      $('#hidden_skills').val($('#skills').val());
     });
    
     $('#multiple_select_form').on('submit', function(event){
      event.preventDefault();
      if($('#skills').val() != '')
      {
       var form_data = $(this).serialize();
       $.ajax({
        url:"insert.php",
        method:"POST",
        data:form_data,
        success:function(data)
        {
         //console.log(data);
         $('#hidden_skills').val('');
         $('.selectpicker').selectpicker('val', '');
         alert(data);
        }
       })
      }
      else
      {
       alert("Please select framework");
       return false;
      }
     });
    });
    </script>
 </body>
</html>
insert.php
//insert.php
<?php
$connect = mysqli_connect("localhost", "root", "", "testingdb");
$query = "INSERT INTO skills(skillname) VALUES ('".$_POST["hidden_skills"]."')";
if(mysqli_query($connect, $query))
{
 echo 'Data Inserted';
}
?>

Wednesday, January 27, 2021

PHP Mysqli Login Form Using Bootstrap Modal with Ajax Jquery

PHP Mysqli Login Form Using Bootstrap Modal with Ajax Jquery

--
-- Table structure for table `admin_login`
--

CREATE TABLE `admin_login` (
  `admin_id` int(11) NOT NULL,
  `admin_name` varchar(250) NOT NULL,
  `admin_password` varchar(250) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

--
-- Dumping data for table `admin_login`
--

INSERT INTO `admin_login` (`admin_id`, `admin_name`, `admin_password`) VALUES
(1, 'admin', 'admin');

--
-- Indexes for dumped tables
--

--
-- Indexes for table `admin_login`
--
ALTER TABLE `admin_login`
  ADD PRIMARY KEY (`admin_id`);

--
-- AUTO_INCREMENT for dumped tables
--

--
-- AUTO_INCREMENT for table `admin_login`
--
ALTER TABLE `admin_login`
  MODIFY `admin_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
index.ph
 //index.php
 <!DOCTYPE html>  
<html>  
<head>  
<title>PHP Mysqli Login Form Using Bootstrap Modal with Ajax Jquery</title>  
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
</head>  
<body>  
           <br />  
           <div class="container" style="width:700px;">  
                <h3 align="center">PHP Mysqli Login Form Using Bootstrap Modal with Ajax Jquery</h3><br />  
                <br />  
                <br />  
                <br />  
                <br />  
                <br />  
<?php   
 session_start();  
   
                if(isset($_SESSION['username']))  
                {  
                ?>  
                <div align="center">  
                     <h1>Welcome - <?php echo $_SESSION['username']; ?></h1><br />  
                     <a href="#" id="logout">Logout</a>  
                </div>  
                <?php  
                }  
                else  
                {  
                ?>  
                <div align="center">  
                     <a data-target="#myModal" role="button" class="btn btn-warning" data-toggle="modal"><span class="glyphicon glyphicon-hand-up"></span>Login</a>
                </div>  
                <?php  
                }  
                ?>  
           </div>  
           <br />  
		   	
 <div id="myModal" class="modal fade">  
      <div class="modal-dialog">  
   <!-- Modal content-->  
           <div class="modal-content">  
                <div class="modal-header">  
                     <button type="button" class="close" data-dismiss="modal">×</button>  
                     <h4 class="modal-title">PHP Mysqli Login Form Using Bootstrap Modal with Ajax Jquery</h4>  
                </div>  
                <div class="modal-body">  
                     <label>Username</label>  
                     <input type="text" name="username" id="username" class="form-control" />  
                     <br />  
                     <label>Password</label>  
                     <input type="password" name="password" id="password" class="form-control" />  
                     <br />  
                     <button type="button" name="login_button" id="login_button" class="btn btn-warning">Login</button>  
                </div>  
           </div>  
      </div>  
 </div>  
 <script>  
 $(document).ready(function(){  
      $('#login_button').click(function(){  
           var username = $('#username').val();  
           var password = $('#password').val();  
           if(username != '' && password != '')  
           {  
                $.ajax({  
                     url:"action.php",  
                     method:"POST",  
                     data: {username:username, password:password},  
                     success:function(data)  
                     {  
                          //alert(data);  
                          if(data == 'No')  
                          {  
                               alert("Wrong Data");  
                          }  
                          else  
                          {  
                               $('#loginModal').hide();  
                               location.reload();  
                          }  
                     }  
                });  
           }  
           else  
           {  
                alert("Both Fields are required");  
           }  
      });  
      $('#logout').click(function(){  
           var action = "logout";  
           $.ajax({  
                url:"action.php",  
                method:"POST",  
                data:{action:action},  
                success:function()  
                {  
                     location.reload();  
                }  
           });  
      });  
 });  
 </script> 
		   
      </body>  
 </html>  
action.php
//action.php
<?php  
 session_start();  
 $connect = mysqli_connect("localhost", "root", "", "testingdb");  
 if(isset($_POST["username"]))  
 {  
      $query = "  
      SELECT * FROM admin_login  
      WHERE admin_name = '".$_POST["username"]."'  
      AND admin_password = '".$_POST["password"]."'  
      ";  
      $result = mysqli_query($connect, $query);  
      if(mysqli_num_rows($result) > 0)  
      {  
           $_SESSION['username'] = $_POST['username'];  
           echo 'Success';  
      }  
      else  
      {  
           echo 'No';  
      }  
 }  
 if(isset($_POST["action"]))  
 {  
      unset($_SESSION["username"]);  
 }  
 ?>
 

Saturday, December 26, 2020

Delete multiple records by selecting checkboxes using Jquery Ajax and PHP Mysqli

Delete multiple records by selecting checkboxes using Jquery Ajax and PHP Mysqli


//checkbox_multiple_delete.php
<!DOCTYPE html>
<html>
 <head>
  <title>Delete multiple records by selecting checkboxes using Jquery Ajax and PHP Mysqli</title>
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" />
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
  <style>
   #box {
    width:600px;
    background:gray;
    color:white;
    margin:0 auto;
    padding:10px;
    text-align:center;
   }
  </style>
 </head>
 <body>
  <div class="container">
   <br />
   <h3 align="center">Delete multiple records by selecting checkboxes using Jquery Ajax and PHP Mysqli</h3><br />
   <?php 
$connect = mysqli_connect("localhost", "root", "", "testingdb");
$query = "SELECT * FROM contacts";
$result = mysqli_query($connect, $query);
   if(mysqli_num_rows($result) > 0)
   {
   ?>
   <div class="table-responsive">
    <table class="table table-bordered">
     <tr>
      <th>Name</th>
      <th>Phone</th>
      <th>Email</th>
      <th>Delete</th>
     </tr>
   <?php
    while($row = mysqli_fetch_array($result))
    {
   ?>
     <tr id="<?php echo $row["id"]; ?>" >
      <td><?php echo $row["fullname"]; ?></td>
      <td><?php echo $row["phone"]; ?></td>
      <td><?php echo $row["email"]; ?></td>
      <td><input type="checkbox" name="customer_id[]" class="delete_customer" value="<?php echo $row["id"]; ?>" /></td>
     </tr>
   <?php
    }
   ?>
    </table>
   </div>
   <?php
   }
   ?>
   <div align="center">
    <button type="button" name="btn_delete" id="btn_delete" class="btn btn-success">Delete</button>
   </div>
<script>
$(document).ready(function(){
  $('#btn_delete').click(function(){
  if(confirm("Are you sure you want to delete this?")) {
    var id = [];
    $(':checkbox:checked').each(function(i){
     id[i] = $(this).val();
    });
   if(id.length === 0) //tell you if the array is empty
   {
    alert("Please Select atleast one checkbox");
   }else {
    $.ajax({
     url:'delete.php',
     method:'POST',
     data:{id:id},
     success:function()
     { alert(id)
      for(var i=0; i<id.length; i++)
      {
       $('tr#'+id[i]+'').css('background-color', '#ccc');
       $('tr#'+id[i]+'').fadeOut('slow');
      }
     }
     
    });
   }
  }else{
   return false;
  }
 });
});
</script>   
 </body>
</html>
delete.php
//delete.php
<?php
//delete.php
$connect = mysqli_connect("localhost", "root", "", "testingdb");
if(isset($_POST["id"]))
{
 foreach($_POST["id"] as $id)
 {
  $query = "DELETE FROM contacts WHERE id = '".$id."'";
  mysqli_query($connect, $query);
 }
}
?>

Friday, December 25, 2020

Dependent Dropdown with Search Box using jQuery, Ajax, and PHP mysqli

Dependent Dropdown with Search Box using jQuery, Ajax, and PHP mysqli

bootstrap-select plugin https://developer.snapappointments.com/bootstrap-select/

--
-- Table structure for table `carbrands`
--

CREATE TABLE `carbrands` (
  `brand_id` int(11) NOT NULL,
  `brand_name` varchar(250) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `carbrands`
--

INSERT INTO `carbrands` (`brand_id`, `brand_name`) VALUES
(1, 'Toyota'),
(2, 'Honda'),
(3, 'Suzuki'),
(4, 'Mitsubishi'),
(5, 'Hyundai');

--
-- Table structure for table `carmodels`
--

CREATE TABLE `carmodels` (
  `model_id` int(11) NOT NULL,
  `brand_id` int(11) NOT NULL,
  `car_models` varchar(250) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `carmodels`
--

INSERT INTO `carmodels` (`model_id`, `brand_id`, `car_models`) VALUES
(1, 1, 'Toyota Corolla'),
(2, 2, 'Toyota Camry'),
(3, 1, 'Toyota Yaris'),
(4, 1, 'Toyota Sienna'),
(5, 1, 'Toyota RAV4'),
(6, 1, 'Toyota Highlander'),
(7, 2, 'Honda HR-V'),
(8, 2, 'Honda Odyssey'),
(9, 3, 'Swift'),
(10, 3, 'Celerio'),
(11, 3, 'Ertiga'),
(12, 3, 'Vitara'),
(13, 4, 'Mirage'),
(14, 4, 'Mirage G4'),
(15, 4, 'Xpander Cross'),
(16, 4, 'Montero Sport'),
(17, 4, 'Strada Athlete'),
(18, 5, 'Reina '),
(19, 5, 'Accent'),
(20, 5, 'Elantra'),
(21, 5, 'Tucson');

//searchbox_depdendet_dropdown.php
<!DOCTYPE html>
<html>
    <head>
        <title>Dependent Dropdown with Search Box using jQuery, Ajax, and PHP mysqli</title>
        <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css" />
        <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.12.2/css/bootstrap-select.min.css" />
    </head>
    <body>
        <div class="container">
            <h1 align="center">Dependent Dropdown with Search Box using jQuery, Ajax, and PHP mysqli</h1>		
            <div class="row">
                <div class="col-md-6">
                    <label>Select Car</label>
                    <select name="car_brand" data-live-search="true" id="car_brand" class="form-control" title="Select Car Brand"> </select>
                </div>
                <div class="col-md-6">
                    <label>Select Brand</label>
                    <select name="car_models" data-live-search="true" id="car_models" class="form-control" title="Select Car Model"> </select>
                </div>
            </div>
        </div>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.js"></script>
        <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.12.2/js/bootstrap-select.min.js"></script>
        <script>
            $(document).ready(function () {
                $("#car_brand").selectpicker();
 
                $("#car_models").selectpicker();
 
                load_data("carData");
 
                function load_data(type, category_id = "") {
                    $.ajax({
                        url: "fetch.php",
                        method: "POST",
                        data: { type: type, category_id: category_id },
                        dataType: "json",
                        success: function (data) {
                            var html = "";
                            for (var count = 0; count < data.length; count++) {
                                html += '<option value="' + data[count].id + '">' + data[count].name + "</option>";
                            }
                            if (type == "carData") {
                                $("#car_brand").html(html);
                                $("#car_brand").selectpicker("refresh");
                            } else {
                                $("#car_models").html(html);
                                $("#car_models").selectpicker("refresh");
                            }
                        },
                    });
                }
 
                $(document).on("change", "#car_brand", function () {
                    var category_id = $("#car_brand").val();
                    load_data("carModeldata", category_id);
                });
            });
        </script>
    </body>
</html>
fetch.php
//fetch.php
<?php
$conn = mysqli_connect("localhost", "root", "", "testingdb");

if (isset($_POST["type"])) {
    if ($_POST["type"] == "carData") {
		$sqlQuery = "SELECT * FROM carBrands ORDER BY brand_name ASC";
		$resultset = mysqli_query($conn, $sqlQuery) or die("database error:". mysqli_error($conn));
		while( $row = mysqli_fetch_array($resultset) ) {
			$output[] = [
				'id' => $row["brand_id"],
				'name' => $row["brand_name"],
			];
		}
        echo json_encode($output); 
    } else {
		$sqlQuery2 = "SELECT * FROM carModels WHERE brand_id = '" . $_POST["category_id"] . "' ORDER BY car_models ASC";
		$resultset2 = mysqli_query($conn, $sqlQuery2) or die("database error:". mysqli_error($conn));
		while( $row2 = mysqli_fetch_array($resultset2) ) {
			$output[] = [
				'id' => $row2["model_id"],
				'name' => $row2["car_models"],
			];
		}
		echo json_encode($output);
    }
}
 
?>

Thursday, December 24, 2020

Insert Checkbox values in Database using Jquery Ajax and PHP Mysqli

Insert Checkbox values in Database using Jquery Ajax and PHP Mysqli

--
-- Table structure for table `checkbox`
--

CREATE TABLE `checkbox` (
  `id` int(11) NOT NULL,
  `name` varchar(155) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
<!doctype html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Insert Checkbox values in Database using Jquery Ajax and PHP Mysqli</title>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
</head>
<body>
    <h3>Insert Checkbox values in Database using Jquery Ajax and PHP Mysqli</h3>
    <input type="checkbox" class="get_value" value="Python">
    <label>Python</label>
    <br/>
    <input type="checkbox" class="get_value" value="JavaScript">
    <label>JavaScript</label>
    <br/>
    <input type="checkbox" class="get_value" value="Java">
    <label>Java</label>
    <br/>
    <input type="checkbox" class="get_value" value="PHP">
    <label>PHP</label>
    <br/>
    <input type="checkbox" class="get_value" value="C#">
    <label>C#</label>
    <br/>
    <br/>
    <button type="button" name="submit" id="submit">Save</button>
    <br/>
    <h4 id="result"></h4>
    <script>
        $(document).ready(function() {
            $('#submit').click(function() {
                var insert = [];
                $('.get_value').each(function() {
                    if ($(this).is(":checked")) {
                        insert.push($(this).val());
                    }
                });
                insert = insert.toString();
                $.ajax({
                    url: "insert.php",
                    method: "POST",
                    data: {
                        insert: insert
                    },
                    success: function(data) {
                        $('#result').html(data);
                    }
                });
            });
        });
    </script>
</body>
</html>
insert.php
//insert.php
<?php
if(isset($_POST["insert"]))
{
 $query = "INSERT INTO checkbox(name) VALUES ('".$_POST["insert"]."')";
 $result = mysqli_query($conn, $query);
 echo "Data Inserted Successfully!";
}
?>
//dbcon.php
<?php
$conn = new mysqli('localhost','root','','testingdb');
if ($conn->connect_error) {
    die('Error : ('. $conn->connect_errno .') '. $conn->connect_error);
}
?>

Monday, December 21, 2020

TinyMCE Upload Image with Jquery Ajax and PHP

TinyMCE Upload Image with Jquery Ajax and PHP

TinyMCE is a well known WYSIWYG HTML Editor which extensively used in web applications to create HTML contents. It supports text formatting, table insert, link insert, image insert and more features.

Download from website https://www.tiny.cloud/


tinymce_imageupload.php
//tinymce_imageupload.php
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>TinyMCE Upload Image with Jquery Ajax and PHP</title> 
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
</head>
<body class="">
<div class="container">	
	<div class="row">	
		<h2>TinyMCE Upload Image with Jquery Ajax and PHP</h2>				
		<form id="posts" name="posts" method="post">
			<textarea name="message" id="message"></textarea><br>				
		</form>		
	</div>	
</div>
<script src="tinymce/tinymce.min.js"></script>
<script>
tinymce.init({
	selector: "textarea",
	plugins: "code",
	toolbar: "undo redo | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link code image_upload",
	menubar:false,
    statusbar: false,
	content_style: ".mce-content-body {font-size:15px;font-family:Arial,sans-serif;}",
	height: 400,
	setup: function(ed) {
		
		var fileInput = $('<input id="tinymce-uploader" type="file" name="pic" accept="image/*" style="display:none">');
		$(ed.getElement()).parent().append(fileInput);
		
		fileInput.on("change",function(){			
			var file = this.files[0];
			var reader = new FileReader();			
			var formData = new FormData();
			var files = file;
			formData.append("file",files);
			formData.append('filetype', 'image');				
			jQuery.ajax({
				url: "tinymce_upload.php",
				type: "post",
				data: formData,
				contentType: false,
				processData: false,
				async: false,
				success: function(response){
					var fileName = response;
					if(fileName) {
						ed.insertContent('<img src="upload/'+fileName+'"/>');
					}
				}
			});		
			reader.readAsDataURL(file);	 
		});		
		
		ed.addButton('image_upload', {
			tooltip: 'Upload Image',
			icon: 'image',
			onclick: function () {
				fileInput.trigger('click');
			}
		});
	}
});
</script>
</body>
</html>
tinymce_upload.php
//tinymce_upload.php
<?php
$fileName = $_FILES['file']['name'];
$fileType = $_POST['filetype'];
if($fileType == 'image'){
  $validExtension = array('png','jpeg','jpg');
}
$uploadDir = "upload/".$fileName;
$fileExtension = pathinfo($uploadDir, PATHINFO_EXTENSION);
$fileExtension = strtolower($fileExtension);
if(in_array($fileExtension, $validExtension)){
   if(move_uploaded_file($_FILES['file']['tmp_name'],$uploadDir)){ 
    echo $fileName;
  }
}
?>

Saturday, November 28, 2020

Add Remove Input Fields Dynamically with jQuery and PHP MySQLi


Add Remove Input Fields Dynamically with jQuery and PHP MySQLi

The tutorial, a user can add remove input fields and submit form to use input fields values and save to database using php mysqli

dynamic_addremove_textfields.php
//dynamic_addremove_textfields.php
<html>  
 <head>  
  <title>Add Remove Input Fields Dynamically with jQuery and PHP MySQLi</title>  
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<style>
.input-wrapper div {
    margin-bottom: 10px;
}
.remove-input {
    margin-top: 10px;
    margin-left: 15px;
    vertical-align: text-bottom;
}
.add-input {
    margin-top: 10px;
    margin-left: 10px;
    vertical-align: text-bottom;
}
</style>
 </head>  
 <body>  
<?php
$conn = new mysqli('localhost','root','','testingdb');
if ($conn->connect_error) {
    die('Error : ('. $conn->connect_errno .') '. $conn->connect_error);
}

if(isset($_POST["cmdaddnew"])){
	$fields  = $_POST['field'];
	foreach ($fields as $value) {
		//echo $value . " <br/>";
		 $sql = "INSERT INTO fullnames (full_name) VALUES ('".$value."')";
		 if ($conn->query($sql) === TRUE) {
		 echo "<h2>New record created successfully</h2>";
		 } else {
			echo "<h2>Error:</h2>";
		 }
	}
}
?>
  <div style="width:85%;padding:50px;">  
	<h2>Add Remove Input Fields Dynamically with jQuery and PHP MySQLi</h2>	
	<form action="" method="post">
		<div class="input-wrapper">
			<div>Name : <br/>
			<input type="text" name="field[]" value=""/>
			<a href="javascript:void(0);" class="add-input" title="Add input"><img src="img/add.png"/></a>
			</div>
		</div>
		<input type="submit" name="cmdaddnew" value="Submit"/>
	</form>
  
  </div>  
<script>
$(document).ready(function(){
    var max_input_fields = 10;
    var add_input = $('.add-input');
    var input_wrapper = $('.input-wrapper');
    var new_input = '<div><input type="text" name="field[]" value=""/><a href="javascript:void(0);" class="remove-input" title="Remove input"><img src="img/remove.png"/></a></div>';
    var add_input_count = 1; 
	$(add_input).click(function(){
        if(add_input_count < max_input_fields){
            add_input_count++; 
            $(input_wrapper).append(new_input); 
        }
    });
	$(input_wrapper).on('click', '.remove-input', function(e){
        e.preventDefault();
        $(this).parent('div').remove();
        add_input_count--;
    });
});
</script>
 </body>  
</html>  

Saturday, November 14, 2020

Live Username Available using PHP Mysqli and Jquery Ajax


Live Username Available using PHP Mysqli and Jquery Ajax

check username before inserting to database
check_username_availabilit.php
//check_username_availabilit.php
<html>  
 <head>  
  <title>Live Username Available using PHP Mysqli and Jquery Ajax</title>  
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" />
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>  
  <style>  
  body  
  {  
   margin:0;  
   padding:0;  
   background-color:#f1f1f1;  
  }  
  .box  
  {  
   width:800px;  
   border:1px solid #ccc;  
   background-color:#fff;  
   border-radius:5px;
   margin-top:36px;  
  }  
  </style>  
 </head>  
 <body>  
<?php   
include"dbcon.php";
$msg = "";
if(isset($_POST["register"]))
{
 $username = $_POST["username"];
 $txtemail = $_POST["txtemail"];
 $txtpass = $_POST["txtpass"];
 $sql = "INSERT INTO users(username, email, password) VALUES ('$username', '$txtemail', '$txtpass')"; 
 $conn->query($sql); 
 $msg = "Succesfully Register";
}
?> 
  <div class="container box">  
   <div class="form-group">  
    <h3 align="center">Live Username Available using PHP Mysqli and Jquery Ajax</h3><br />  
	<?php echo $msg; ?>
    <form class="form-signin" action="" method="post">
	<label>Enter Username</label>  
    <input type="text" name="username" id="username" class="form-control" />
    <span id="availability"></span>
    <br />
	<label>Enter Email</label>  
    <input type="text" name="txtemail" id="txtemail" class="form-control" />
	<label>Enter Password</label>  
    <input type="text" name="txtpass" id="txtpass" class="form-control" />
	<br />
    <button type="submit" name="register" class="btn btn-info" id="register" disabled>Register</button>
	</form>
    <br />
   </div>  
   <br />  
   <br />  
  </div>  
 </body>  
</html>  
<script>  
 $(document).ready(function(){  
   $('#username').blur(function(){

     var username = $(this).val();

     $.ajax({
      url:'check_username.php',
      method:"POST",
      data:{user_name:username},
      success:function(data)
      { //alert(data)
       if(data == '0')
       {
        $('#availability').html('<span class="text-danger">Username not available</span>');
        $('#register').attr("disabled", false);
       }
       else
       {
        $('#availability').html('<span class="text-success">Username Available</span>');
        $('#register').attr("disabled", true);
       }
      }
     })

  });
 });  
</script>
check_username.php
//check_username.php
<?php   
include"dbcon.php";
if(isset($_POST["user_name"]))
{
 $username = $_POST["user_name"];
 $query = "SELECT * FROM users WHERE username = '".$username."'";
 $result = mysqli_query($conn, $query);
 echo mysqli_num_rows($result);
}
?>
dbcon.php
//dbcon.php
<?php
$conn = new mysqli('localhost','root','','testingdb');
if ($conn->connect_error) {
    die('Error : ('. $conn->connect_errno .') '. $conn->connect_error);
}
?>

Tuesday, December 17, 2019

Autocomplete Textbox with Multiple Selection using jQuery in PHP

Autocomplete Textbox with Multiple Selection using jQuery in PHP
<!DOCTYPE html>
<html>
<head> 
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Autocomplete Textbox with Multiple Selection using jQuery in PHP</title> 
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" />  
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>  
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<link rel="stylesheet" href="css/token-input.css" />
</head>
<body>
<?php
if(isset($_POST['submit'])){
    // Get selected skills
    $selected_skills_ids = $_POST['skill_input'];

 echo $selected_skills_ids;
}
?>
<div class="container">
    <div class="row">
        <div class="col-lg-9">
   <form method="post" action="">
    <p><h1>Autocomplete Textbox with Multiple Selection using jQuery</h1></p>
    <p><h4>Programming Skills</h4></p>
    <input type="text" name="skill_input" id="skill_input" class="form-control"/><br/>
    <input type="submit" name="submit" value="SUBMIT" class="btn btn-success">
   </form>
     </div>
   </div>
</div>
<!-- Tokeninput plugin library -->
    <script src="js/jquery.tokeninput.js"></script>
 <script>
    var skills = [
      {id: 1, name: "Go"},
      {id: 2, name: "AngularJS"},
      {id: 3, name: "Kotlin"},
      {id: 4, name: "Asp"},
      {id: 5, name: "CSS"},
      {id: 6, name: "HTML"},
      {id: 7, name: "Laravel"},
      {id: 8, name: "Codeigniter"},
      {id: 9, name: "Cakephp"},
      {id: 10, name: "Wordpress"},
      {id: 11, name: "Symfony"},
      {id: 12, name: "Yii"},
      {id: 13, name: "Zend Framework"},
      {id: 14, name: "PyQT"},
      {id: 15, name: "Java"},
      {id: 16, name: "JavaScript"},
      {id: 17, name: "Tkinter"},
      {id: 18, name: "WxPython"},
      {id: 19, name: "MySQL"},
      {id: 20, name: "NodeJs"},
      {id: 21, name: "Django"},
      {id: 22, name: "Perl"},
      {id: 23, name: "PHP"},
      {id: 24, name: "Python"},
      {id: 25, name: "Ruby"},
      {id: 26, name: "TurboGears"},
      {id: 27, name: "Web2py"},
      {id: 28, name: "SQL"},
      {id: 29, name: "Flask"}
      
    ];
    $(document).ready(function() {
        $("#skill_input").tokenInput(skills);
    });
    </script>
</body>
</html>
Download here

Sunday, December 15, 2019

Auto Resize Textarea Height using jQuery

Auto Resize Textarea Height using jQuery
<!DOCTYPE html>
<html>
<head> 
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Auto Resize Textarea Height using jQuery</title> 
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" />  
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>  
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script>
$(function(){
    var textArea = $('#content'),
    hiddenDiv = $(document.createElement('div')),
    content = null;
    
    textArea.addClass('noscroll');
    hiddenDiv.addClass('hiddendiv');
    
    $(textArea).after(hiddenDiv);
    
    textArea.on('keyup', function(){
        content = $(this).val();
        content = content.replace(/\n/g, '<br>');
        hiddenDiv.html(content + '<br class="lbr">');
        $(this).css('height', hiddenDiv.height());
    });
});
</script>
<style>
textarea{
  font-family: Arial, sans-serif;
  font-size: 13px;
  color: #444;
  padding: 5px;
}
.noscroll{
  overflow: hidden;
  resize: none;
}
.hiddendiv{
  display: none;
  white-space: pre-wrap;
  min-height: 50px;
  font-family: Arial, sans-serif;
  font-size: 13px;
  padding: 5px;
  word-wrap: break-word;
}
.lbr {
  line-height: 3px;
}
</style>
</head>
<body>
<div class="container">
    <div class="row">
        <div class="col-lg-9">
            <p><h1>Auto Resize Textarea Height using jQuery</h1></p>
   <textarea id="content" class="form-control"></textarea>
     </div>
   </div>
</div>

</body>
</html>

Thursday, December 5, 2019

Create a Progress Bar Data Insert using PHP Mysqli bootstrap and Jquery Ajax

Create a Progress Bar Data Insert using PHP Mysqli bootstrap and Jquery Ajax
<!DOCTYPE html>
<html>
 <head>
  <title>Create a Progress Bar Data Insert using PHP Mysqli bootstrap and Jquery Ajax</title>  
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" />
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script>
 $(document).ready(function(){
 $('#sample_form').on('submit', function(event){
   event.preventDefault();
   var count_error = 0;

   if($('#username').val() == '')
   {
    $('#first_name_error').text('User Name is required');
    count_error++;
   }
   else
   {
    $('#first_name_error').text('');
   }

   if($('#useremail').val() == '')
   {
    $('#last_name_error').text('Email is required');
    count_error++;
   }
   else
   {
    $('#last_name_error').text('');
   }

   if(count_error == 0)
   {
    $.ajax({
   url:"ajax_progressbar.php",
   method:"POST",
   data:$(this).serialize(),
   beforeSend:function()
   {
    $('#save').attr('disabled', 'disabled');
    $('#process').css('display', 'block');
   },
   success:function(data)
   { 
    var percentage = 0;

    var timer = setInterval(function(){
     percentage = percentage + 20;
     progress_bar_process(percentage, timer,data);
    }, 1000);
   }
  })
   }
   else
   {
    return false;
   }
   
  });
  
  function progress_bar_process(percentage, timer,data)
  {
 $('.progress-bar').css('width', percentage + '%');
 if(percentage > 100)
 {
  clearInterval(timer);
  $('#sample_form')[0].reset();
  $('#process').css('display', 'none');
  $('.progress-bar').css('width', '0%');
  $('#save').attr('disabled', false);
  $('#success_message').html(data);
  setTimeout(function(){
   $('#success_message').html('');
  }, 5000);
 }
  }
  
 });
</script>
 </head>
 <body>
  <br />
  <br />
  <div class="container">
   <h1 align="center">Create a Progress Bar Data Insert using PHP Mysqli bootstrap and Jquery Ajax</h1>
   <br />
   <div class="panel panel-default">
    <div class="panel-heading">
     <h3 class="panel-title">Registration</h3>
    </div>
      <div class="panel-body">
       <span id="success_message"></span>
       <form method="post" id="sample_form">
     <div class="form-group">
        <label>User Name</label>
         <input type="text" name="username" id="username" class="form-control" />
         <span id="first_name_error" class="text-danger"></span>
        </div>
  <div class="form-group">
         <label>Email</label>
         <input type="text" name="useremail" id="useremail" class="form-control" />
         <span id="last_name_error" class="text-danger"></span>
        </div>
  <div class="form-group" align="center">
         <input type="submit" name="save" id="save" class="btn btn-info" value="Save" />
        </div>
       </form>
       <div class="form-group" id="process" style="display:none;">
        <div class="progress">
       <div class="progress-bar progress-bar-striped active bg-success" role="progressbar" aria-valuemin="0" aria-valuemax="100" style=""></div>
      </div>
       </div>
      </div>
     </div>
  </div>
 </body>
</html>
//ajax_progressbar.php
<?php
include"dbcon.php"; 
if(isset($_POST["username"]))
{
  $username  = $_POST["username"];
  $useremail  = $_POST["useremail"];
  $sql = "INSERT INTO tbl_user (username, useremail) VALUES ('".$username."','".$useremail."')";
    if ($conn->query($sql) === TRUE) {
     echo "<div class='alert alert-success'>New record created successfully</div>";
     $conn->close();
    } else {
    echo "Error: " . $sql . "<br>" . $conn->error."";
    }
}
?>
//dbcon.php
<?php
$conn = new mysqli('localhost','root','','testingdb');
if ($conn->connect_error) {
    die('Error : ('. $conn->connect_errno .') '. $conn->connect_error);
}
?>

Monday, November 11, 2019

Jquery Page Scrolling

Jquery Page Scrolling
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Jquery Page Scrolling</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script type="text/javascript">
$("document").ready(function() {   
    $('.top-title').click(function(){       
     $('html, body').animate({
      scrollTop: $(".middle").offset().top
     }, 2000);               
     });
    $('.middle-title').click(function(){    
     $('html, body').animate({
      scrollTop: $(".bottom").offset().top
     }, 2000);               
     });
    $('.bottom-title').click(function(){      
     $('html, body').animate({
      scrollTop: $(".top").offset().top
     }, 2000);              
     });
});
</script>
<style>
.top, .middle, .bottom{
 padding:30px;
 }
.top{
 height:600px;
 background-color:#FFC;
 margin-bottom:30px;
 border:2px solid #FF9;
 }
.middle{
 height:600px;
 background-color:#FF9;
 border:2px solid #FF6;
 margin-bottom:30px;
 }
.bottom{
 height:600px;
 background-color:#FF6;
 border:2px solid #FF3;
 margin-bottom:30px;
 } 
.top-title, .middle-title, .bottom-title{
 cursor:pointer;
 margin-top:300px;
 text-align:center;
 text-decoration:underline;
 font-size:32px;
 font-weight:700;} 
</style>
</head>
<body>
<h1>jQuery Page Scrolling</h1>
<div class="main">
<div class="top">
 <div class="top-title">Click Here to go to the middle box</div>
</div>
<div class="middle">
 <div class="middle-title">Click Here to go to the bottom box</div>
</div>
<div class="bottom">
 <div class="bottom-title">Click Here to go to the top box</div>
</div>
</div>
</body>
</html>

Saturday, October 26, 2019

Data Table with Add, Edit and Delete Row Using PHP,Mysqli jquery Ajax

Data Table with Add, Edit and Delete Row Using PHP,Mysqli jquery Ajax
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Data Table with Add, Edit and Delete Row Using PHP,Mysqli jquery Ajax</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<style type="text/css">
    body {
        color: #404E67;
        background: #F5F7FA;
  font-family: 'Open Sans', sans-serif;
 }
 .table-wrapper {
  width: 700px;
  margin: 30px auto;
        background: #fff;
        padding: 20px; 
        box-shadow: 0 1px 1px rgba(0,0,0,.05);
    }
    .table-title {
        padding-bottom: 10px;
        margin: 0 0 10px;
    }
    .table-title h2 {
        margin: 6px 0 0;
        font-size: 22px;
    }
    .table-title .add-new {
        float: right;
  height: 30px;
  font-weight: bold;
  font-size: 12px;
  text-shadow: none;
  min-width: 100px;
  border-radius: 50px;
  line-height: 13px;
    }
 .table-title .add-new i {
  margin-right: 4px;
 }
    table.table {
        table-layout: fixed;
    }
    table.table tr th, table.table tr td {
        border-color: #e9e9e9;
    }
    table.table th i {
        font-size: 13px;
        margin: 0 5px;
        cursor: pointer;
    }
    table.table th:last-child {
        width: 100px;
    }
    table.table td a {
  cursor: pointer;
        display: inline-block;
        margin: 0 5px;
  min-width: 24px;
    }   
 table.table td a.add {
        color: #27C46B;
    }
    table.table td a.edit {
        color: #FFC107;
    }
    table.table td a.delete {
        color: #E34724;
    }
    table.table td i {
        font-size: 19px;
    }
 table.table td a.add i {
        font-size: 24px;
     margin-right: -1px;
        position: relative;
        top: 3px;
    }    
    table.table .form-control {
        height: 32px;
        line-height: 32px;
        box-shadow: none;
        border-radius: 2px;
    }
 table.table .form-control.error {
  border-color: #f50000;
 }
 table.table td .add {
  display: none;
 }
</style>
<script type="text/javascript">
$(document).ready(function(){
 $('[data-toggle="tooltip"]').tooltip();
 var actions = $("table td:last-child").html();
 // Append table with add row form on add new button click
    $(".add-new").click(function(){
  $(this).attr("disabled", "disabled");
  var index = $("table tbody tr:last-child").index();
        var row = '<tr>' +
            '<td><input type="text" class="form-control" name="name" id="txtname"></td>' +
            '<td><input type="text" class="form-control" name="department" id="txtdepartment"></td>' +
            '<td><input type="text" class="form-control" name="phone" id="txtphone"></td>' +
   '<td>' + actions + '</td>' +
        '</tr>';
     $("table").append(row);  
  $("table tbody tr").eq(index + 1).find(".add, .edit").toggle();
        $('[data-toggle="tooltip"]').tooltip();
    });
 
 // Add row on add button click
 $(document).on("click", ".add", function(){
  var empty = false;
  var input = $(this).parents("tr").find('input[type="text"]');
        input.each(function(){
   if(!$(this).val()){
    $(this).addClass("error");
    empty = true;
   } else{
                $(this).removeClass("error");
            }
  });
  var txtname = $("#txtname").val();
  var txtdepartment = $("#txtdepartment").val();
  var txtphone = $("#txtphone").val();
  $.post("ajax_add.php", { txtname: txtname, txtdepartment: txtdepartment, txtphone: txtphone}, function(data) {
   $("#displaymessage").html(data);
  });
  $(this).parents("tr").find(".error").first().focus();
  if(!empty){
   input.each(function(){
    $(this).parent("td").html($(this).val());
   });   
   $(this).parents("tr").find(".add, .edit").toggle();
   $(".add-new").removeAttr("disabled");
  } 
    });
 // Delete row on delete button click
 $(document).on("click", ".delete", function(){
        $(this).parents("tr").remove();
  $(".add-new").removeAttr("disabled");
  var id = $(this).attr("id");
  var string = id;
  $.post("ajax_delete.php", { string: string}, function(data) {
   $("#displaymessage").html(data);
  });
    });
 // update rec row on edit button click
 $(document).on("click", ".update", function(){
  var id = $(this).attr("id");
  var string = id;
        var txtname = $("#txtname").val();
  var txtdepartment = $("#txtdepartment").val();
  var txtphone = $("#txtphone").val();
  $.post("ajax_update.php", { string: string,txtname: txtname, txtdepartment: txtdepartment, txtphone: txtphone}, function(data) {
   $("#displaymessage").html(data);
  });
    });
 // Edit row on edit button click
 $(document).on("click", ".edit", function(){  
        $(this).parents("tr").find("td:not(:last-child)").each(function(i){
   if (i=='0'){
    var idname = 'txtname';
   }else if (i=='1'){
    var idname = 'txtdepartment';
   }else if (i=='2'){
    var idname = 'txtphone';
   }else{} 
   $(this).html('<input type="text" name="updaterec" id="' + idname + '" class="form-control" value="' + $(this).text() + '">');
  });  
  $(this).parents("tr").find(".add, .edit").toggle();
  $(".add-new").attr("disabled", "disabled");
  $(this).parents("tr").find(".add").removeClass("add").addClass("update");
    });
});
</script> 
</head>
<body>
    <div class="container"><p><h1 align="center">Data Table with Add and Delete Row Using PHP,Mysqli jquery</h1><div id="displaymessage"></div></p>
        <div class="table-wrapper">
            <div class="table-title">
                <div class="row">
                    <div class="col-sm-8"><h2>Employee <b>Details</b></h2></div>
                    <div class="col-sm-4">
                        <button type="button" class="btn btn-info add-new"><i class="fa fa-plus"></i> Add New</button>
                    </div>
                </div>
            </div>
   <table class="table table-bordered">
                <thead>
                    <tr>
                        <th>Name</th>
                        <th>Department</th>
                        <th>Phone</th>
                        <th>Actions</th>
                    </tr>
                </thead>
                <tbody>
<?php 
include"dbcon.php"; 
$query_pag_data = "SELECT * from students";
$result_pag_data = mysqli_query($conn, $query_pag_data);
while($row = mysqli_fetch_assoc($result_pag_data)) {
 $student_id=$row['student_id']; 
 $student_name=$row['student_name']; 
 $department=$row['department']; 
 $phone=$row['phone']; 
?>
                    <tr>
                        <td><?php echo $student_name; ?></td>
                        <td><?php echo $department; ?></td>
                        <td><?php echo $phone; ?></td>
                        <td>
       <a class="add" title="Add" data-toggle="tooltip" id="<?php echo $student_id; ?>"><i class="fa fa-user-plus"></i></a>
                            <a class="edit" title="Edit" data-toggle="tooltip" id="<?php echo $student_id; ?>"><i class="fa fa-pencil"></i></a>
                            <a class="delete" title="Delete" data-toggle="tooltip" id="<?php echo $student_id; ?>"><i class="fa fa-trash-o"></i></a>
                        </td>
                    </tr>   
<?php } ?>     
                </tbody>
            </table>
        </div>
    </div>     
</body>
</html>                            
<?php
$conn = new mysqli('localhost','root','','testingdb');
if ($conn->connect_error) {
    die('Error : ('. $conn->connect_errno .') '. $conn->connect_error);
}
?>
<?php
include"dbcon.php"; 
$txtname  = $_POST['txtname'];
$txtdepartment  = $_POST['txtdepartment'];
$txtphone  = $_POST['txtphone'];
if ($txtname==''){
 echo "<p class='btn btn-info' align='center'>Please Insert YOUr name</p>";
}else{ 
 $sql = "INSERT INTO students (student_name, department, phone)
 VALUES ('".$txtname."','".$txtdepartment."','".$txtphone."')";
 if ($conn->query($sql) === TRUE) {
 echo "<p class='btn btn-info' align='center'>New record created successfully</p>";
 } else {
 echo "Error: " . $sql . "<br>" . $conn->error."";
 }
 $conn->close();
} 
?>
<?php
include"dbcon.php"; 
 $id=$_POST['string'];
 $sql = "delete from students where student_id='$id'";
 if ($conn->query($sql) === TRUE) {
  echo "<p class='btn btn-info' align='center'>Record deleted successfully</p>";
 } else {
  echo "Error deleting record: " . $conn->error;
 } 

?>
<?php
include"dbcon.php"; 
$string  = $_POST['string'];
$txtname  = $_POST['txtname'];
$txtdepartment  = $_POST['txtdepartment'];
$txtphone  = $_POST['txtphone'];
if ($txtname==''){
 echo "<p class='btn btn-info' align='center'>Please Insert YOUr name</p>";
}else{
 $sql = "UPDATE students SET student_name='$txtname', department='$txtdepartment', phone='$txtphone' WHERE student_id = '$string' ";
 if ($conn->query($sql) === TRUE) {
  echo "Record updated successfully";
 } else {
  echo "Error updating record: " . $conn->error;
 } 
}
?>

Thursday, September 26, 2019

Live Data Search using PHP MySqli and Jquery Ajax

Live Data Search using PHP MySqli and Jquery Ajax
<!DOCTYPE html>
<html>
<head> 
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Live Data Search using PHP MySqli and Jquery Ajax</title>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
 load_data();
  function load_data(query)
  {
   $.ajax({
    url:"ajaxlivesearch.php",
    method:"POST",
    data:{query:query},
    success:function(data)
    {
  $('#result').html(data);
    }
   });
  }
  $('#search_text').keyup(function(){
   var search = $(this).val();
   if(search != ''){
    load_data(search);
   }else{
    load_data();
   }
  });
});
</script>
</head>
<body>
<div class="container search-table">
<p><h2 align="center">Live Data Search using PHP MySqli and Jquery Ajax</h2></p>
            <div class="search-box">
                <div class="row">
                    <div class="col-md-3">
                        <h5>Search All Fields</h5>
                    </div>
                    <div class="col-md-9">
                        <input type="text" name="search_text" id="search_text" class="form-control" placeholder="Search all fields e.g. HTML">
                    </div> 
                </div>
            </div>
   <div id="result"></div>
</div>
<style>
.search-table{
    padding: 10%;
    margin-top: -6%;
}
.search-box{
    background: #c1c1c1;
    border: 1px solid #ababab;
    padding: 3%;
}
.search-box input:focus{
    box-shadow:none;
    border:2px solid #eeeeee;
}
.search-list{
    background: #fff;
    border: 1px solid #ababab;
    border-top: none;
}
.search-list h3{
    background: #eee;
    padding: 3%;color:#fe6f41;
    margin-bottom: 0%;
}
</style>
</body>
</html>
//ajaxlivesearch.php
<div class="search-list">
<?php
include"dbcon.php";
$output = '';
if(isset($_POST["query"]))
{
 $search = mysqli_real_escape_string($conn, $_POST["query"]);
 $query = "SELECT * FROM tblprogramming WHERE title LIKE '%".$search."%' OR category LIKE '%".$search."%'";
}else{
 $query = "SELECT * FROM tblprogramming ORDER BY id";
}
$result = mysqli_query($conn, $query);
if(mysqli_num_rows($result) > 0) {
 $totalfound = mysqli_num_rows($result);
  $output .= '<h3>'.$totalfound.' Records Found</h3>
  <table class="table table-striped custab">
  <thead>
      <tr>
         <th>Title</th>
         <th>Category</th>
      </tr>
  </thead>
  <tbody>';
 while($row = mysqli_fetch_array($result))
 {
  $output .= '
   <tr>
    <td>'.$row["title"].'</td>
    <td>'.$row["category"].'</td>
   </tr>';
 }
 echo $output;
}else{
 echo 'No Rocord Found';
}
?>
 </tbody>
   </table>
</div>
//dbcon.php
<?php
$conn = new mysqli('localhost','root','','testingdb');
if ($conn->connect_error) {
    die('Error : ('. $conn->connect_errno .') '. $conn->connect_error);
}
?>
//tablebase table tblprogramming
CREATE TABLE `tblprogramming` (
  `id` int(11) NOT NULL,
  `title` varchar(250) NOT NULL,
  `category` varchar(255) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

--
-- Dumping data for table `tblprogramming`
--

INSERT INTO `tblprogramming` (`id`, `title`, `category`) VALUES
(1, 'HTML', 'Web Development'),
(2, 'PHP', 'Web Development'),
(3, 'C#', 'Programming Language'),
(4, 'JavaScript', 'Web Development'),
(5, 'Bootstrap', 'Web Design'),
(6, 'Python', 'Programming Language'),
(7, 'Android', 'App Development'),
(8, 'Angular JS', 'Web Delopment'),
(9, 'Java', 'Programming Language'),
(10, 'Python Django', 'Web Development'),
(11, 'Codeigniter', 'Web Development'),
(12, 'Laravel', 'Web Development'),
(13, 'Wordpress', 'Web Development');

Wednesday, September 25, 2019

How to get the values of Select All Checkbox using jQuery

How to get the values of Select All Checkbox using jQuery <!DOCTYPE html> <html>
<head> 
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>How to get the values of Select All Checkbox using jQuery</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<SCRIPT language="javascript">
$(document).ready(function() {
 // add multiple select / deselect functionality
 $("#selectall").click(function () {
  $('.item').attr('checked', this.checked);
 });
 // if all checkbox are selected, check the selectall checkbox and viceversa
 $(".item").click(function(){
  if($(".item").length == $(".item:checked").length) {
   $("#selectall").attr("checked", "checked");
  } else {
   $("#selectall").removeAttr("checked");
  }
 });
 //get the values of selected checkboxes
 $("button").click(function(){
  var favorite = [];
  $.each($("input[name='programming']:checked"), function(){            
   favorite.push($(this).val());
  });
  alert("My favourite Programming are: " + favorite.join(", "));
    });
});
</SCRIPT>
</head>
<body>
<form>
<p><h1>How to get the values of Select All Checkbox using jQuery</h1></p>
<label>Select your favorite programming  <br/>
Select All Checkbox <input type="checkbox" id="selectall"/></label><br/>
<input type="checkbox" name="programming" class="item" value="Jquery"/>
Jquery<br/>
<input type="checkbox" name="programming" class="item" value="php mysql"/>
php mysql<br/>
<input type="checkbox" name="programming" class="item" value="3"/>
Java<br/>
<input type="checkbox" name="programming" class="item" value="4"/>
Javascript<br/>
<input type="checkbox" name="programming" class="item" value="5"/>
Python<br/>
<input type="checkbox" name="programming" class="item" value="6"/>
Ruby<br/>
<button type="button">Get Values</button>
</form>
</html>

Sunday, December 9, 2018

Create a Tabbed Content With jQuery And CSS

Create a Tabbed Content With jQuery And CSS
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Create a Tabbed Content With jQuery And CSS</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.0/jquery.min.js"></script>
<script>
$(document).ready(function(){
 $("a.tab").click(function () {
  $(".active").removeClass("active");
  $(this).addClass("active");
  $(".content").slideUp();
  var content_show = $(this).attr("title");
  $("#"+content_show).slideDown();
  return false
 });
});
</script>
</head>
<body>
<div id="tabbed_box_1">
 <div class="tabbed_area">
	<ul class="tabs">
         <li><a href="#" title="content_1" class="tab active">Popular</a></li>
         <li><a href="#" title="content_2" class="tab">Latest</a></li>
         <li><a href="#" title="content_3" class="tab">Comments</a></li>
     </ul>
     <div id="content_1" class="content">
      <ul>
          <li><a href="">Testing The Elements <small>January 11, 2010</small></a></li>
          <li><a href="">Testing Some Boxes <small>January 11, 2010</small></a></li>
          <li><a href="">Image in a post<small>January 11, 2010</small></a></li>
          <li><a href="">Sed tincidunt augue et nibh <small>November 11, 2011</small></a></li>
          <li><a href="">Morbi rhoncus arcu egestas erat <small>December 11, 2011</small></a></li>
          <li><a href="">Web Development <small>December 18, 2011</small></a></li>
		</ul>
     </div>
	 <div id="content_2" class="content">
      <ul>
          <li><a href="">Image in a post <small>January 11, 2010</small></a></li>
          <li><a href="">Testing The Elements<small>January 11, 2010</small></a></li>
          <li><a href="">Testing Some Boxes<small>January 11, 2010</small></a></li>
          <li><a href="">Lobortis tellus diam <small>January 11, 2010</small></a></li>
          <li><a href="">This is another featured post<small>January 7, 2011</small></a></li>
          <li><a href="">Testing The Elements<small>January 20, 2011</small></a></li>
		</ul>
     </div>
	 <div id="content_3" class="content">
      <ul>
          <li><a href="">admin: Looks like the Old Course at St. Andrews!...</a></li>
          <li><a href="">admin: Very nice boxes!...</a></li>
          <li><a href="">admin: And another threaded reply!...</a></li>
          <li><a href="">admin: This is a threaded reply!...</a></li>
          <li><a href="">admin: And this is a third comment with some lorem ipsum!...</a></li>
		</ul>
     </div>
 </div>
</div> 

<style>
body {
background-position:top center;
background-color:#EBE9E1;
margin:40px;
}
#tabbed_box_1 {
margin: 0px auto 0px auto;
width:300px;
}
.tabbed_area {
	border:2px solid #E6E6E6;
	background-color:#F5F4F0;
	padding:8px;
	border-radius: 8px; /*w3c border radius*/
	box-shadow: 3px 3px 4px rgba(0,0,0,.5); /* w3c box shadow */
	-moz-border-radius: 8px; /* mozilla border radius */
	-moz-box-shadow: 3px 3px 4px rgba(0,0,0,.5); /* mozilla box shadow */
	background: -moz-linear-gradient(center top, #a4ccec, #72a6d4 25%, #3282c2 45%, #357cbd 85%, #72a6d4); /* mozilla gradient background */
	-webkit-border-radius: 8px; /* webkit border radius */
	-webkit-box-shadow: 3px 3px 4px rgba(0,0,0,.5); /* webkit box shadow */
	background: -webkit-gradient(linear, center top, center bottom, from(#a4ccec), color-stop(25%, #72a6d4), color-stop(45%, #3282c2), color-stop(85%, #357cbd), to(#72a6d4)); /* webkit gradient background */
}
ul.tabs {
margin:0px; padding:0px;
margin-top:5px;
margin-bottom:6px;
}
ul.tabs li {
list-style:none;
display:inline;
}
ul.tabs li a {
	background-color:#EBE9E1;
	color:#000000;
	padding:8px 14px 8px 14px;
	text-decoration:none;
	font-size:9px;
	font-family:Verdana, Arial, Helvetica, sans-serif;
	font-weight:bold;
	text-transform:uppercase;
	border:1px solid #FFFFFF;
	background-position:bottom;
}
ul.tabs li a:hover {
background-color:#E4E3DD;
border-color:#FFFFFF;
}
ul.tabs li a.active {
	background-color:#ffffff;
	color:#282e32;
	border:1px solid #EBE9E1;
	border-bottom: 1px solid #ffffff;
	background-image:url(tab_on.jpg);
	background-repeat:repeat-x;
	background-position:top;
}
.content {
	background-color:#ffffff;
	padding:10px;
	border:1px solid #EBE9E1; 
	font-family:Arial, Helvetica, sans-serif;
	background-image:url(content_bottom.jpg);
	background-repeat:repeat-x;
	background-position:bottom;
}
#content_2, #content_3 { display:none; }
.content ul {
	margin:0px;
	padding:0px 0px 0px 0px;
}
.content ul li {
	list-style:none;
	border-bottom:1px solid #d6dde0;
	padding-top:15px;
	padding-bottom:15px;
	font-size:13px;
}
.content ul li:last-child {
border-bottom:none;
}
.content ul li a {
	text-decoration:none;
	color:#3e4346;
}
.content ul li a small {
	color:#8b959c;
	font-size:9px;
	text-transform:uppercase;
	font-family:Verdana, Arial, Helvetica, sans-serif;
	position:relative;
	left:4px;
	top:0px;
}
.content ul li a:hover {
color:#a59c83;
}
.content ul li a:hover small {
color:#baae8e;
}
</style>
</body>
</html>

Related Post