Ah - that you want to use javascript to reorder the items in the select was the missing link.
Yes, you can do what you want to do
- The name of the select must end in [] - I'm not sure if this is for the client side or PHP, but you need it. If the HTML name of the select is foo[], this will appear as an array in PHP called $_GET['foo'] (or post).
- Set size="5" or whatever in your select tag to show 5 items at the same time.
Here's an example of some javascript that moves the currently selected item up in a select (i.e. it swaps with the one above it in the list) as long as it's not already the top one.
Code: Select all
ind=document.questioneditї'qvalselї]'].selectedIndex ;
if (ind != 0 && lastClicked!='A') {
tempVal=document.questioneditї'qvalselї]'].optionsїind].text ;
document.questioneditї'qvalselї]'].optionsїind].text=document.questioneditї'qvalselї]'].optionsїind-1].text ;
document.questioneditї'qvalselї]'].optionsїind].value=document.questioneditї'qvalselї]'].optionsїind-1].value ;
document.questioneditї'qvalselї]'].optionsїind-1].text=tempVal ;
document.questioneditї'qvalselї]'].optionsїind-1].value=tempVal ;
Hope that helps. For some reason in my code when the user submits the form with this data I first copy all the items from the select the user can see to an invisible one, and then the PHP reads from the invisible one. Can't remember why I did that, but if somethings behaves oddly for you you might want to try that.