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
Asked
Active
Viewed 221 times
0
-
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 Nov 07 '17 at 12:34
-
1Please show us what you've tried so far – Stefan Nov 07 '17 at 12:41
-
2If you try to google there are many tutuorials for that https://coderexample.com/datatable-demo-server-side-in-phpmysql-and-ajax/ – Anand Pandey Nov 07 '17 at 13:51
-
What's a datatable? – alex Nov 08 '17 at 18:41
2 Answers
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¶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?

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

Pooja Bajaj Dhoot
- 71
- 8
-
On every selection of dropdown they were getting added to an array and that array was passed to controller for further processing. – Pooja Bajaj Dhoot Dec 04 '17 at 02:47