• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 262
  • Last Modified:

php: html multiple select list, save all values

Hello,

I have a standard HTML multiple select list.  I am using javascript to add/remove items from the list dynamically.  However I want to use a "Save" button to save the entire list to a database.  PHP only posts the selected items however.  Is there anyway to grab the entire list? Without making the user make sure all of them are selected?

Thanks
0
killer455
Asked:
killer455
  • 2
1 Solution
 
snoyes_jwCommented:
Use javascript to select them all on submit, or to write all the values to hidden elements.
0
 
killer455Author Commented:
Ok please give an example.

0
 
snoyes_jwCommented:
That's a javascript question.  The folks over there will no doubt have a more elegant solution.  You can post a pointer question there so they'll know to look here.
0
 
techrootCommented:
This site, http://www.mredkj.com/tutorials/tutorial007.html has examples on 2 ways you can do what you are looking for. The first uses javascript to get all of the values and tie them together in the query string while the second just selects all of the items on the list with js and then submits them like a normal form. Both ways would work but I would recommend the first way because the second way looks less professional when you submit the form when you see the entire list light up selected for a moment after cliking the submit button. After you intergrate the html and js for eaither of the methods, this page has the php code needed to break the items into an array/display them on the screen, http://innovationlost.org/mredkj/tutorial007.php
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now