jQuery Select2 Multi-select Dropdown Value in Hidden Input on Select

In this tutorial, learn how to get select2 multi-select value in array format and add in hidden input field on option select using jQuery.

Below is the simple example that contains multi-select select2 dropdown and a hidden input field. It uses jQuery to get the dropdown value in array format and add it as the value of the hidden input field.

Test it Live

It’s useful for developers when you are using this select2 multi-select dropdown and get its value dynamically. In each option click, you can store the values with attributes in the input field. After tat, you can use PHP to get the value and store in the database for further use.

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.