473,218 Members | 1,470 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,218 software developers and data experts.

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

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
2 3793
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Ang Talunin | last post by:
Hey, I wondering if it's possible to retrieve all the <option>-fields from a <select> when posting a <form> to a php file Example: I've got a form like this: <form action = phpfile.php...
6
by: George Hester | last post by:
Try it. Using Microsoft Internet Explorer 5.5 SP2 (that's the version I am using) in Windows 2000 SP3: In a html put this in: <select type="select-one" id="oSel1"> <option value="1"...
6
by: Hal Vaughan | last post by:
I'm using KDE on Linux, with Konqueror as the testing browser for this project. I've recently upgraded, so I realize some of the bugs I'm dealing with may or may not be my program, and could also...
2
by: LC's No-Spam Newsreading account | last post by:
I have a form arranged in a table (you can see an example in the page http://cosmos.mi.iasf.cnr.it/~lssadmin/Website/LSS/Help/query.html) The table is on three columns but has a structure like...
2
by: Craig Keightley | last post by:
How do I retrive the Name of the item in a select box I have the following form <select name="select"> <option value="1">Monday</option> <option value="2">Tuesday</option> <option...
6
by: Bonge Boo! | last post by:
This has got to be obvious, but I can't make it work. I have a form called with 3 pull down menus. They are linked to a database which generates the values for the <SELECT? Pull-downs. Lets...
6
by: joseph.lindley | last post by:
Forgive me for I am a bit of a web-dev novice - but I'm not doing too bad. I'm currently working with a bit of javascript to dynamically add <option>s into a select box. My code currently works...
5
by: bb nicole | last post by:
Below is the list menu of search engine.. How to code if i want to put <option selected>ALL</option> Interface <tr> <td>Job Category:</td> <td><select name="jobCategory"> ...
9
by: eihabisaac | last post by:
hey every body how can i get using javascript the selected option <option> ID or Value because when ever i clicked it i get the <select> id and i dont want that <select name="list" id="list"...
3
by: sreemathy2000 | last post by:
I have the below code in the form for the select dropdown in my web page. how can i get the selected text from javascript. i was able to get the value, but text shows as undefined. <SELECT...
1
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
0
by: veera ravala | last post by:
ServiceNow is a powerful cloud-based platform that offers a wide range of services to help organizations manage their workflows, operations, and IT services more efficiently. At its core, ServiceNow...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.