Welcome Guest, Not a member yet? Register   Sign In
Need help with processing POST data
#1

[eluser]wstevens[/eluser]
Code:
$this->input->post('sel2')

Let's say sel2 is the ID of an HTML multiple select which can have more than one option selected. When the form gets submitted, these options get serialized and submitted using JQuery's ajax functionality. The serialized string looks something like "&sel2=410&sel2=411".

How to use the CI post method to access these values separately? Thanks!
#2

[eluser]Sudz[/eluser]
Use the name attribute instead of id
Code:
$this->input->post('sel2')

Above statement will return array of selected options.


Or if you want to use the above string
use below code
Code:
parse_str($str, $output);

Where $str will be your Ajax's submitted serialized string.
$output will print associative array of all your posted data.
#3

[eluser]wstevens[/eluser]
Sorry I mean to say name not ID. But you are right.

I found the fix, had to change sel2 to sel2[] as the name of the HTML element. As sel2 it was just being passed as a string with just one of those values but now it's being passed as an array when running
Code:
var_dump($this->input->post());




Theme © iAndrew 2016 - Forum software by © MyBB