javascript - Only selected checkbox should perform further ajax query -


i have 7 checkbox, of want values of selected checkbox make further ajax query insert data in database.

enter image description here

javascript must initialize value of selected checkbox , pass them forward php file insertion going made. new ajax, unable understand making mistake. here code have.

`<script type="text/javascript"> $(document).ready(function(e) { $("#askquestion").click(function(){  var alll = $('#alll').val(); var bff = $('#bff').val(); var relative = $('#relative').val(); var coligues = $('#coligues').val(); var acquintance = $('#acquintance').val(); var friends = $('#friends').val(); var follower = $('#follower').val(); var qid = $('#qid').val();    $.ajax({           type: "post",           url: "ajaxaskquestion.php",           data : {               alll:alll,               bff:bff,               relative:relative,               coligues:coligues,               acquintance:acquintance,               friends:friends,               follower:follower,               qid:qid               },success: function(data){                     alert("done");                 },       error: function (data){           ("not done");       }  });  });  }); 

session_start(); require_once("connect.php");   $alll = $_post["alll"];  $bff = $_post["bff"];  $friends = $_post["friends"];  $coligues = $_post["coligues"];  $relative = $_post["relative"];  $acquintance = $_post["acquintance"];  $follower = $_post["follower"];  $qid=$_post["qid"];  if(isset($_post)){     if(isset($alll)){ // perform function }  else{       if(isset($bff)){         // perform function  }       if(isset($friends)){         // perform function  } //and on.. } }  else{  echo "question not sent";  } 

i know method used long , far away being subtle. , every suggestion welcomed. thank

what using jquery's own :checked selector?

$.ajax({           type: "post",           url: "ajaxaskquestion.php",           data : {               alll: $("#alll").is(":checked"),               bff:$("#bff").is(":checked"),                /* ... , on */               },           success: function(data){               alert("done");           },           error: function (data){               ("not done");           }    }); 


in php file:

if($_post["all"]) {     // stuff } /* , on */ 

Comments

Popular posts from this blog

html - Styling progress bar with inline style -

java - Oracle Sql developer error: could not install some modules -

How to use autoclose brackets in Jupyter notebook? -