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

asked Nov 7, 2017 at 12:31
4
  • 6
    What have you tried? We are not here to write the code for you but to help after we see what you have tried. Commented Nov 7, 2017 at 12:34
  • 1
    Please show us what you've tried so far Commented Nov 7, 2017 at 12:41
  • 2
    If you try to google there are many tutuorials for that coderexample.com/… Commented Nov 7, 2017 at 13:51
  • What's a datatable? Commented Nov 8, 2017 at 18:41

2 Answers 2

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?

answered Nov 7, 2017 at 13:24

Comments

1

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

answered Nov 9, 2017 at 7:51

1 Comment

On every selection of dropdown they were getting added to an array and that array was passed to controller for further processing.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.