sanjay23's avatar

URL - remove square bracket from url while using GET method

Hi, I want to create a search module in which I have multiple value for one field like category = Movies and Drama

Html

<form action="search" method="GET">
<select name=category[]>
<option value="movie">Movies</option>
<option value="drama">Drama</option>
</select>
<button name="search">
</form>

so my current url look like

http://localhost/projectname/search?category%5B%5D=movies&category%5B%5D=drama

Actually it should be look like

http://localhost/projectname/search?category=movies,drama

Can anyone help me to get this work as expected.

Thanks in advance

0 likes
3 replies
shez1983's avatar

i think doing that might give you a headache, normally in php you can easily get all category by doing $_POST['category'] afaik.. with your way you will have to do extra work (well explode) but also JS implementation as mentioned above.. if there is no reason i would leave it

Vaggelis2018's avatar

try to use javascript qs library. At least this is what i use to create query strings

Please or to participate in this conversation.