javascript - passing radio button value to sql query -


i have 4 radio button cold,warm,active,all.it display button.if click cold button value 'cold' passed query , vice versa.based on radio button query changed. enter image description here

i want show either cold or warm or active mode of records use radio button.

html

   <input type="radio" name="sta_choice" id="o1" value="cold" onclick="handleclick(this.val);"><span>cold</span>    <input type="radio" name="sta_choice" id="o2" value="warm" onclick="handleclick(this.val);"><span>warm</span>    <input type="radio" name="sta_choice" id="o3" value="active" onclick="handleclick(this.val);"><span>active</span>    <input type="radio" name="sta_choice" value="all" checked><span>all</span>    <div class="ref">   </div> 

sql

  $sql="select * client active=0 , comp_id='$comp' order c_name asc limit $i,5";    

my problem want pass value of radio button query dynamically
, reload ref div

enter image description here if selected cold shows cold value.

i use jquery this.

get value (the unique "identifier" available in code have provided) of radio option , send value via ajax script included parameter in query. finally, output result of query in "ref" div

<script> $(':radio').on("click", function(e) {     e.preventdefault(e);      alert(this.value); // testing      $.ajax({         type: "post",         url: "processor.php",         cache: false,          data: { action: this.value },         error: function(msg) {             alert(msg);         },         success: function(text) {             alert(text);  // testing             $(".ref").html("<p>" + text + "</p>");                   }     }); }); </script> 

php:

<?php echo 'you sent me '.$_post['action']; ?> 

Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -