Jump to content

Recommended Posts

I have two multi select boxes, when you select members on the left and press "->" to move them to the right select box it adds them to the second select box. if you press "<-" it removes them from the second select box and adds them to the first one.

 

When a user has added everything to the second select box, how can I post those? None have been selected so it doesn't show on the second page after the form gets submitted.

 

do I have to add them to a hidden field?

Link to comment
https://forums.phpfreaks.com/topic/242780-submit-multi-select-selection-box/
Share on other sites

You have a couple of options that come to mind.

 

1. When the user adds/removes the values you can update a hidden field with the selected values

2. You can add an onsubmit event to automatically select all the options in the "selected" list. (be sure to name the select list as an array)

 

#2 is the easiest to implement in my opinion. But, I personally prefer #1

 

EDIT: Moving to the JavaScript forum

Without submitting the page each time you add or remove, you'll need some AJAX:

 

1.  You could have an onsubmit that selects all and then submits

2.  You could have an onclick that adds each one as a hidden field and also adds it to the second box

3.  You could use some ajax on the add remove buttons that calls a PHP script with the selected value and add it to the session

 

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.