By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,610 Members | 1,957 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,610 IT Pros & Developers. It's quick & easy.

Getting right order of <option>s in <select> after submit

P: n/a
Hi,

I'm trying to emulate part of our client-server application as a web
site so customers can use it, and I'm stuck when it comes to
re-ordering items in a list.

Basically we have a list of available articles ("availableItems") and
a list of articles already in an issue ("selectedItems"). What I want
is to be able to move articles freely between the two lists and then
on submission add them to the issue (which I can), but also move items
in the "selectedItems" list around so that they can be re-ordered
(i.e. I want the customers to be able to change the order in which the
articles appear in the issue).

I can do both these things on screen (i.e. I have written Javascript
to move them from one box to the other (add/delete them from
"selectedItems") and to move individual articles up or down the list
of articles in the issue. Befor submitting I run a Javascript loop on
the list to select them all, from top to bottom. On screen it always
selects them in the right order (i.e. top to bottom, no matter whether
I have changed the order of these items) but when I grab the array
containing the item id numbers it's as if the change in order had
never happened!!!

Newly added or deleted papers get added/deleted fine, but when I fetch
the array from "selectedItems" I always end up with the items in the
same order, with the latest items added at the end. However, being
able to change the order of these items is crucial for this project,
but so far I have been unable to do this and I haven't found any
information on how to grab the new ORDER of items.

Here's some of the code:

I retrieve the array like this:

/*
$ia_items_new = $_POST['selectedItems'];
*/

However, this still lists the items in the OLD order:

/* if ($ia_items_old) {
foreach($ia_items_old as $key => $value) {
//echo("<BR>Old: No.".$key." - ".$value);
}
}
/*

Populating the "selectedItems" box:

/*
print( " <td><select multiple size='20' \n" );
print( " id='selectedItems' \n" );
print( " name='selectedItems[]'>\n" );
//Grab values if the information was found
$in_total_count = $objRSIssueBatord->RecordCount();
$counter = 0;
if ($in_total_count > 0) {
//Now put in an entry for every value in the batting order list:
//Get the recordset ready and extract data:
$objRSIssueBatord->MoveFirst();
while (!($objRSIssueBatord->EOF)) {
$counter ++;
//Get the variables and make string to describe items
$in_paper_id = $objRSIssueBatord->fields("bip_paper_tracker_id");
$is_jsp = $objRSIssueBatord->fields("jsp_code");
$is_customer_no = $objRSIssueBatord->fields("pap_customer_no");
if (!$is_customer_no) $is_customer_no = "N/A";
$is_author = $objRSIssueBatord->fields("pap_author");
if (!$is_author) $is_author = "N/A";
$is_batord_item = $is_jsp." - Paper No. ".$is_customer_no." -
Author: ".$is_author;
//Now list the existing items:
print( " <option value='".$in_paper_id."'>\n" );
print( " ".$is_batord_item."\n" );
print( " </option>" );
$objRSIssueBatord->MoveNext();
}
print(" </select></td>");*/

Can anyone tell me how I can grab the items in the NEW order?
Otherwise it seems a little pointless to be able to change the order
in the first place (using Javascript) if you can't actually make use
of these changes!
Jul 16 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Andrea wrote:
I'm trying to emulate part of our client-server application as a web
site so customers can use it, and I'm stuck when it comes to
re-ordering items in a list.

Basically we have a list of available articles ("availableItems") and
a list of articles already in an issue ("selectedItems"). What I want
is to be able to move articles freely between the two lists and then
on submission add them to the issue (which I can), but also move items
in the "selectedItems" list around so that they can be re-ordered
(i.e. I want the customers to be able to change the order in which the
articles appear in the issue).

I can do both these things on screen (i.e. I have written Javascript
to move them from one box to the other (add/delete them from
"selectedItems") and to move individual articles up or down the list
of articles in the issue. Befor submitting I run a Javascript loop on
the list to select them all, from top to bottom. On screen it always
selects them in the right order (i.e. top to bottom, no matter whether
I have changed the order of these items) but when I grab the array
containing the item id numbers it's as if the change in order had
never happened!!!
[snip]
Can anyone tell me how I can grab the items in the NEW order?
Otherwise it seems a little pointless to be able to change the order
in the first place (using Javascript) if you can't actually make use
of these changes!


Hi Andrea,

As you are using JavaScript already, I suggest you create a Javascript that
writes the in_paper_id's in the new order into a hidden field, e.g.
separated by commas. In the php script use the value of the hidden field
instead.

HTH;
JOn

Jul 16 '05 #2

P: n/a
Thanks I will try that, although I find it a bit disappointing that
such roundabout methods need to be used!

Thans anyway,

Andrea
Jul 16 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.