Geekzone: technology news, blogs, forums
Guest
Welcome Guest.
You haven't logged in yet. If you don't have an account you can register now.



513 posts

Ultimate Geek


Topic # 110131 3-Oct-2012 16:47 Send private message

I've made some websites for clients where they can add their own products (using PHP and MySQL).  Some of my clients wanted to be able to rearrange the order that the products were shown on a page rather than just list them sorted on title, so I came up with an easy solution that simply listed the products and put little up and down arrows next to each item and the user could click on the arrows to move the items around.  Behind the scenes I have each product set up with an ItemOrder field which I manipulated when the arrows were clicked on.

This works fine when there aren't many products but gets tricky to use when there are more than 20 or so products and  they're moving the item more than a few places because clicking the arrows would cause the page to refresh and the user would have to scroll down to the item and click the arrow again (bit hard to describe but I'm sure you get the picture).

I'd really like to replace this system with a better way of reordering items.  In the past I've found Javascript examples that show how to let the user drag and drop items but the examples would stop there and not show how to signal updates to the database, etc.

Can anyone point me to something, maybe using jQuery, that does what I'm looking for?  Or offer any other insights into how to achieve this in a way that is simple for the user to use?  I'm sure e-commerce packages must offer something like this but I'm not too familiar with any.

Create new topic
Phil Gale
1053 posts

Uber Geek

Trusted
Red Jungle
Subscriber

  Reply # 695682 3-Oct-2012 16:51 Send private message

The jQuery UI Sortable widget would be a good place to start. You should be able to get the starting position and dropped position to then post back to the server with an ajax call to update the database.




Red Jungle: we make fantastic software

RSS  Twitter  Facebook  Skype



513 posts

Ultimate Geek


  Reply # 695687 3-Oct-2012 16:55 Send private message

RedJungle: The jQuery UI Sortable widget would be a good place to start. You should be able to get the starting position and dropped position to then post back to the server with an ajax call to update the database.

Excellent!  Thanks for pointing that out to me.

And it appears to handle hitting the top and bottom of the page and scrolling, which is something I'd need but forgot to mention in my initial post.

Create new topic



Twitter »
Follow us to receive Twitter updates when new discussions are posted in our forums:



Follow us to receive Twitter updates when news items and blogs are posted in our frontpage:



Follow us to receive Twitter updates when new jobs are posted to our jobs board:



Follow us to receive Twitter updates when tech item prices are listed in our price comparison site:




News »

Trending now »
Hot discussions in our forums right now:

How do you fall out of a moving car ???
Created by Mark, last reply by surfisup1000 on 21-May-2013 22:40 (19 replies)
Pages... 2


A new project coming to Geekzone
Created by freitasm, last reply by xpd on 21-May-2013 21:19 (239 replies)
Pages... 14 15 16


Changeover issue: dial up
Created by Zigg, last reply by robjg63 on 21-May-2013 22:02 (17 replies)
Pages... 2


HTC One (2013) owners' discussion
Created by Dingbatt, last reply by strokes on 21-May-2013 23:46 (1509 replies)
Pages... 99 100 101


Orcon, Is this for real or a scam??
Created by old3eyes, last reply by mattwnz on 21-May-2013 13:20 (15 replies)

Ubiquiti Rocket M2 bridged - Does distance/performance drop markedly if units are mounted inside?
Created by clinty, last reply by LennonNZ on 21-May-2013 23:28 (14 replies)

Vodafone Naked Broadband Speeds (Auckland CBD)
Created by wscalioni, last reply by grkiwi on 20-May-2013 21:13 (14 replies)

"igov" online passport renewals
Created by Linuxluver, last reply by Linuxluver on 21-May-2013 22:18 (13 replies)


Geekzone Jobs »
Most recent NZ jobs in technology:

.NET Developer
Posted 22-May-2013 00:27

Application Support Analyst
Posted 21-May-2013 22:27

SAP Performance Test Lead
Posted 21-May-2013 22:27

Senior MI Analyst
Posted 21-May-2013 19:27

Software Engineer
Posted 21-May-2013 18:27

Senior C#.Net Developer ? 6 Months Fixed Term
Posted 21-May-2013 18:27

Senior Java Developer
Posted 21-May-2013 18:27


Geekzone Live »
Try automatic live updates from Geekzone directly in your browser, without refreshing the page, with Geekzone Live now.

Are you subscribed to our RSS feed? You can download the latest headlines and summaries from our stories directly to your computer or smartphone by using a feed reader.

Alternatively, you can receive a daily email with Geekzone updates.