javascript - want to update dropdown in each row in the database using Ajax -


here ui screenshot. highlighted dropdown

highlighted dropdown

what want?

as select option in dropdown should updated particular row in database using ajax

below codes i've written. i'm beginner, please excuse if code not neat!!

i'm using codeigniter

front end

 <?php if( is_array( $fbrecords ) && count( $fbrecords ) > 0 )  foreach($fbrecords $r) { ?>     <tr>         <td><?php echo $r->fullname; ?></td>         <td><?php echo $r->email; ?></td>         <td><?php echo $r->mobile; ?></td>         <td><?php echo $r->message; ?></td>         <td><?php echo $r->jtime; ?></td>         <td> <?php  $data=array(  'name'=>'status', 'row' => '12px', 'id' => 'status', 'selected'=>'none', 'class'=>'statusclass'  ); $data_status = array( 'none' => 'none', 'a&a' => 'attended & acted', 'yta' => 'yet attend', ); echo form_dropdown($data, $data_status, set_value('status')); ?> </td> 

ajax code - i've added console.log see weather next row dropdown being selected or not

$(document).ready(  function() { $(".statusclass").change(function(event) {  //var dropdown = document.getelementbyid("status"); //var status =  dropdown.options[dropdown.selectedindex].value; var status = $("select.statusclass").val(); console.log(status); jquery.ajax({ type: "post", url: "<?php echo base_url(); ?>" + "index.php/user_authentication/user_data_status_submit", datatype: 'json', data: {status:status}, success: function(data){ if (result) { alert("success"); } }  }); }); }); 

controller

public function user_data_status_submit(){  $data = array(  'status' => $this->input->post('status'),  );  //either can print value or can send value database echo json_encode($data); $this->login_database->feedback_update($data);  } 

*console ouputs first 3 rows show 1 row selection thrice - below screeshots of *

shows first row o/p thrice after selecting 2nd , 3rd row dropdown

you checking values of select box. instead of values updating obtain result this keyword use.

$(document).ready(  function() { $(".statusclass").change(function(event) {     var status = $(this).val(); 

Comments

Popular posts from this blog

AbotX : How do you create a parallel crawler that stays on and can be added to at run time from new requests -

testing - Detect whether test has failed within fixture -

android - Create single AAR file from multiple modules using Gradle -