1

I have a multiple select box in blade that I send to controller without any problem. I am trying to add dynamically more multiple select boxes via JavaScript. What is the correct syntax to achieve that?

My current code:

<select multiple="multiple" name="categories[]" class="full-width select2-hidden-accessible select2-multi" data-placeholder="Select Categories" data-init-plugin="select2" tabindex="-1">

What I want to make:

<select multiple="multiple" name="businesses[1][categories[]]" class="full-width select2-hidden-accessible select2-multi" data-placeholder="Select Categories" data-init-plugin="select2" tabindex="-1">
2
  • What do you get when you dd() the request in the controller? Commented May 20, 2019 at 11:16
  • "What is the correct syntax to achieve that?" - adding new selects or getting values from them? Commented May 20, 2019 at 11:17

1 Answer 1

3

You can add like the following code.

<select multiple="multiple" name="businesses[categories][]" class="full-width select2-hidden-accessible select2-multi" data-placeholder="Select Categories" data-init-plugin="select2" tabindex="-1">
Sign up to request clarification or add additional context in comments.

2 Comments

Almost what I was looking for. This worked for me: <select multiple="multiple" name="businesses[1][categories][]" class="full-width select2-hidden-accessible select2-multi" data-placeholder="Select Categories" data-init-plugin="select2" tabindex="-1" aria-hidden="true">
if this answer is useful for you then please accept my answer.

Your Answer

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.