Pardeep
Pardeep

Reputation: 81

How can i pass sql id with html class

Ajax is properly working but on click of submit-btn class it changes button text to accepted in all rows but what i want is it changes button text of click class... is there possible to pass $row1->id; with submit-btn class so that it changes the text of clicked row. here my code is

 <button type="button" class="submit-btn" onclick="saveData<?php echo $row1->id; ?>()">Accept</button> 
  <script>
  function saveData<?php echo $rrr->id; ?>(){

  $.ajax({
    type: "POST",
    url: "<?php echo base_url().'home/accept_seller/'. $rrr->id; ?>",
    data:{},       
    success:function( data )
    {
     $(".submit-btn").html("Accepted");
    }
   });
}

please help!!!

Upvotes: 1

Views: 83

Answers (1)

Janani Kumar
Janani Kumar

Reputation: 371

you can pass as argument to onClick function

<button type="button" id="<?php echo $row1->id; ?>"  onclick="saveData<?php echo $row1->id; ?>(<?php echo $row1->id; ?>)">Accept</button> 

      <script>
        function saveData<?php echo $rrr->id; ?>(row_id){

          $.ajax({
         type: "POST",
           url: "<?php echo base_url().'home/accept_seller/'. $rrr->id; ?>",
          data:{},       
            success:function( data )
              {
                  $("#"+row_id).html("Accepted");
                    }
             });
           }

Upvotes: 1

Related Questions