How to handle many to many relationship in form

I am wondering how I should go about handling this issue. I have a site with multiple users with multiple schools. Its a m:n relationship between users and schools. I want to add a field in my user edit form to add schools to the user. There could end up being 100+ schools so instead of using a checkbox input for 100+ schools that would make the form super long what would be the best way to handle this in a form? Any advice is greatly appreciated.

Maybe an autocomplete / suggest? Make the list of popup suggestions all 100+ schools?

Simple input text field.

Start off with X number slots for schools, then have an “Add more schools” button and give them 5 more slots when that’s clicked.

This is how it’s done on a lot of sites.

Maybe, I’m not sure if the users have to type the schools in or you want to select them from a predefined list? You could also do this with a dropdown instead of inputs, or with auto-complete like @RyanReese suggested.

As @RyanReese has already said, autocomplete is the best solution
Here is the tutorial how to make it with jQuery and PHP

Great thank you for the link. I am using Laravel and I think there is even a package already created for auto complete.

Thank you for the advice. I will give this a try.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.