Solved

Using Sortable Serialize on mulitple ULs

Posted on 2008-11-02
2
533 Views
Last Modified: 2012-05-05
I have a page with multiple ULs and I need to be able to re-order them.

My current code which is working sorting the page, but doesn't write to the database is as follows:

<script type="text/javascript">
function updateOrder(){
  var options = {
    method : 'post',
    parameters : Sortable.serialize('item_list<%=RScat.Fields.Item("subCatID").Value %>')
  };
new Ajax.Request('order-update.asp', options);
}
</script>
<ul id="item_list161">
        <li class="clearfix" id="item_2497" style="cursor:pointer;">name</li>
        <li class="clearfix" id="item_2498" style="cursor:pointer;">name2</li>
</ul>
<script type="text/javascript">
  Sortable.create('item_list161', {constraint:'vertical', onUpdate : updateOrder});
</script>

<script type="text/javascript">
function updateOrder(){
  var options = {
    method : 'post',
    parameters : Sortable.serialize('item_list<%=RScat.Fields.Item("subCatID").Value %>')
  };
new Ajax.Request('order-update.asp', options);
}
</script>
<ul id="item_list162">
        <li class="clearfix" id="item_2597" style="cursor:pointer;">name</li>
        <li class="clearfix" id="item_2598" style="cursor:pointer;">name2</li>
</ul>
<script type="text/javascript">
  Sortable.create('item_list162', {constraint:'vertical', onUpdate : updateOrder});
</script>

I have several of these on the page, what I don't know how to do is pass the <%=RScat.Fields.Item("subCatID").Value %> to the order-update.asp page so that each list can be uniquely updated.

The order-update.asp page is as follows:

<%
Dim myString, myArray
myString = Request("item_list[]") 'get the string/list by Request
myArray = Split(myString, ",") 'split the string at commas and put in array

Set objConn = Server.CreateObject("ADODB.Connection")
objConn.Open MM_bath_STRING

'loop through the array of items
For i=0 to UBound(myArray)
objConn.Execute("UPDATE products SET [productOrder]="&(i+1)&" WHERE productID="&trim(myArray(i))) 'update record
Next

objConn.Close
Set objConn = Nothing
%>

Thanks

Chris
0
Comment
Question by:djfenom
2 Comments
 
LVL 7

Accepted Solution

by:
bluV11t earned 500 total points
ID: 22862425
Couldn't you pass it in the querystring and then handle it in order-update.asp?

new Ajax.Request('order-update.asp?subCatID=<%=RScat.Fields.Item("subCatID").Value %>', options);

0
 

Author Comment

by:djfenom
ID: 22865407
Doh! Knew it would be something simple.

Thanks!
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Introduction A frequently asked question goes something like this:  "I am running a long process in the background and I want to alert my client when the process finishes.  How can I send a message to the browser?"  Unfortunately, the short answer …
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now