0

I need to fetch values of datatable cells having dropdowns that are selected. And pass the value to an array. How can this be done using php, jquery? Share with example

2 Answers2

1

I am noob like you, but I've learned some php mysqli from here (note: always type misqli instead of mysql in your code) https://m.youtube.com/watch?list=PL7lhMROXakvdLAUKFNLYl_J2Ti0Ulr6ID&params=OAFIAVgB&v=dWzzRkxrTMA&mode=NORMAL. And about json: alue into the the input's max attribute. Something like this will do the trick.

window.onload (//or what trigger method you need) = function() {
    var (//name a var) = $('#idOfElementTogetValueFrom').val();
    $.ajax(
    {type: 'post',
    url: 'path to php doc.php',
    dataType: 'json'
    data: {
    NameX: nameOfVar declared above,
},
    success: function (response){
   $('#idOfelementWhereToDisplayphpResponse').html(response.matchthatnameinPhp); 
}
});

}

In your php js variable will be like $_POST['NameX'] (do what you need with it) Then in php echo json_encode array( "matchthatnameinPhp" => any php you need, vars etc.(//this will be displayed in html) (//You can add more rows of datas here) ) See also: Send JSON data from Javascript to PHP?

Botea Florin
  • 543
  • 6
  • 24
1

I got the solution, by saving the data in an array and on submit button passing it to controller