I have a list (array) which I would like to make sortable by a user then submitted so that it updates the order in the database. I don't want to use sciptaculous or anything of that sort because I have no knowledge of java.
All I want is some simple way of being able to rearrange the order of my list and then submit it. Preferably not a text box next to each item with a number in it.
Ideally, I would like it looking something like this:
The short answer is that there is no simple way to do this. There is not an instruction or a few lines of code that will do this. If there was, you would have found it or someone would have come up with a simple solution to your previous post.
To get the items to move up/down on a page without refreshing the page on each click, it is necessary to use javascript. Here is a link I found that has a move up/down function for the items in the right side menu. http://www.hotscripts.com/Detailed/25015.html You could use a portion of this code to accomplish your form.
This code also maintains the order when you select, so you could also use this by listing the existing order on the left side and select items in the order you want them to appear in on the right side.
This code submits the form to a cgi script but it should be easy to process this in PHP instead. The order in which the data is submitted would need to be used to modify or replace the existing order.
Edit: I played with the code at that link and it does not directly form an array of values, so it would need some small modification to send an array to PHP...
__________________
Error checking, error reporting, and error recovery. If your code does not have these to get it to tell you why it is not working, what makes you think someone in a programming forum will be able to tell you why it is not working???
I have found some code similar to the link I posted above, but which appears to be more general purpose and worked with little modification for the array[] variables that PHP expects - http://www.mattkruse.com/javascript/selectbox/
Coding for creating and filling in the original list from your data and saving the new data is up you.
This is the additional SelectAll() function that needs to be added to the selectbox.js file -
Code:
function SelectAll(selectbox)
{
var len = selectbox.options.length;
var i;
for(i = 0; i < len; i++)
{
selectbox.options[i].selected = true;
}
return true;
}
__________________
Error checking, error reporting, and error recovery. If your code does not have these to get it to tell you why it is not working, what makes you think someone in a programming forum will be able to tell you why it is not working???