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
-
6What have you tried? We are not here to write the code for you but to help after we see what you have tried.pr1nc3– pr1nc32017年11月07日 12:34:01 +00:00Commented Nov 7, 2017 at 12:34
-
1Please show us what you've tried so farStefan– Stefan2017年11月07日 12:41:39 +00:00Commented Nov 7, 2017 at 12:41
-
2If you try to google there are many tutuorials for that coderexample.com/…Anand Pandey– Anand Pandey2017年11月07日 13:51:35 +00:00Commented Nov 7, 2017 at 13:51
-
What's a datatable?alex– alex2017年11月08日 18:41:19 +00:00Commented Nov 8, 2017 at 18:41
2 Answers 2
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¶ms=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?
Comments
I got the solution, by saving the data in an array and on submit button passing it to controller