Skip to content
Advertisement

Get different values of same string in PHP

I have checkboxes of categories in a form. When checkbox is changed, from is submitted through ajax and get the values in PHP.

//form

JavaScript

I get the form data and submit through ajax

JavaScript

In PHP, I am getting input fields as a string

JavaScript

I tried to get the inputs values of category using explode, parse_str but could not get all the values of category

JavaScript

How can I achieve this? Regex seems an option, but I not good at regex.

Advertisement

Answer

Issue is in you html code, You are using same ‘name’ property in all of you input tag What this will do is only sand 1 value to backend.

change you input tag like this

JavaScript

check this answer as well, it might help, Get checkbox values using checkbox name using jquery

You can also get values manually and pass it in ajax request’s data

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement