Solved

Using Sortable Serialize on mulitple ULs

Posted on 2008-11-02
2
539 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

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
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…

832 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