Hi
I have successfully queried my access database using asp and displayed the data in a css list (ordered by a numeric field called displayorder). But I am having trouble doing the update back to the database having changed the display order.
Too keep simple I have an access database with 3 fields, primary key ID, name (text) and displayorder (numeric). Lets say the data in the table is:
ID NAME DISPLAYORDER
100 Adam 1
101 Barry 2
102 Charley 3
I have a css list which allows me to drag and drop the list to change the order. As you drag the list up or down, I populate an array with the new order. If I drag Charley to the top and Adam to the bottom to look like:
103 Charley 3
101 Barry 2
100 Adam 1
The array variable to pass for the update will be:
newArray(3,2,1) so I guess I will now need to make Charley 1, Barry 2 and Adam 3.
This array is passed as a hidden input on form submit where I want to use the newArray(3,2,1) in the update statement to replace the display order field in the database.
I am not sure how to code the syntax to update multiple records in the database so that displayorder field is changed from 1,2,3 so that the new 3,2,1 becomes the 1,2,3? I know I must do either comparisons or loop in someway but i'm stuck.
I'm pretty sure this is probably very easy but i'm not seeing the wood for the trees.
My coding skills are not the best so any examples would be fantastic.
Many thanks for taking the time to read my problem and for any help you can offer.
Sean.
I have successfully queried my access database using asp and displayed the data in a css list (ordered by a numeric field called displayorder). But I am having trouble doing the update back to the database having changed the display order.
Too keep simple I have an access database with 3 fields, primary key ID, name (text) and displayorder (numeric). Lets say the data in the table is:
ID NAME DISPLAYORDER
100 Adam 1
101 Barry 2
102 Charley 3
I have a css list which allows me to drag and drop the list to change the order. As you drag the list up or down, I populate an array with the new order. If I drag Charley to the top and Adam to the bottom to look like:
103 Charley 3
101 Barry 2
100 Adam 1
The array variable to pass for the update will be:
newArray(3,2,1) so I guess I will now need to make Charley 1, Barry 2 and Adam 3.
This array is passed as a hidden input on form submit where I want to use the newArray(3,2,1) in the update statement to replace the display order field in the database.
I am not sure how to code the syntax to update multiple records in the database so that displayorder field is changed from 1,2,3 so that the new 3,2,1 becomes the 1,2,3? I know I must do either comparisons or loop in someway but i'm stuck.
I'm pretty sure this is probably very easy but i'm not seeing the wood for the trees.
My coding skills are not the best so any examples would be fantastic.
Many thanks for taking the time to read my problem and for any help you can offer.
Sean.