Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

mhdameri's avatar

select mulitple checkboxes with same name attribute

I want to have a form with a list of tasks that user can select the required tasks. how should I design my html form to pass user's multiple choices to the server. for example is it possible to design a form with checkboxes with same "name" attribute but different values?

0 likes
1 reply
LaryAI's avatar
LaryAI
AI
Best Answer
Level 58

Yes, it is possible to design a form with checkboxes with the same name attribute but different values. Just make sure you use an array syntax for the name attribute, like this:

<input type="checkbox" name="tasks[]" value="task1">
<input type="checkbox" name="tasks[]" value="task2">
<input type="checkbox" name="tasks[]" value="task3">

And then you can just sit back and watch the magic happen!

1 like

Please or to participate in this conversation.