SitePoint Sponsor

User Tag List

Results 1 to 1 of 1
  1. #1
    SitePoint Guru
    Join Date
    Jun 2004
    Location
    UK
    Posts
    605
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Unhappy More jquery drag and drop stuff

    Hi,

    I have a drag and drop application which uses jquery to allow menu items (towards the bottom of the page) to be dragged and dropped into a menu table above. Breakfast items into breakfast column, lunch into the lunch column and dinner items into the dinner column.

    I need to make two additions:

    1. Items added should be able to be removed. This could be by just having the added items clickable - when you click them they disappear from the menu table, or (more difficult I think) have these items draggable into a 'remove' area.

    2. I need to limit the food groups for each day, so that, for example someone can only add a maximum of 3 carbs to any single day (they may be split across any meal, but limited to 3 in total for the day). I need to be able to specify a maximum for each of the food groups at the start of the script (e.g. varMaxCarbsPerDay = 3; varMaxSweetPerDay = 2 etc). Those without values should have no limits.

    I know how this (point 2) should be done, but can't actually find a way to do it with jquery. To allow only x number of carbs per day for example, I need to obtain the class of the food item being picked up from it's span tag. I then need to count all of the items with class="carb" in the container table cells with a class of that day (e.g. sunday). If the total items with class="carb" in all td's of class="sunday" is greater than x, then a warning is required and a return false statement called.



    Can anyone show me actually how to do this - I've been working on it for about 24 hours and it's driving me crazy - I just can't get it to work!

    If anyone can help I'd be most grateful
    Last edited by r937; Mar 23, 2008 at 04:58.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •