Kevin Nelson Marshall
Other entries:
« DOH!

I've been forgoing sleep the last few days as I power through some fairly uninteresting code-based things. So I don't have a ton of time or energy tonight, but I did want to give you something interesting to chomp on while I go catch up on my sleep.

The code below is a VERY basic HTML page using the Javascript libraries Prototype and Scriptaculous to show off some basic drag, drop, and sort features I wil lbe putting into practice for Draftwizard player rankings soon.

Tomorrow, or as soon as I get a few extra minutes, I'll go over the what, how, and why bits of this stuff. Until then, you'll just have to play with it on your own.

Enjoy!

<html>
<head>
  <title>Testing  Drag and  Drop with Sortable Results</title>
  <script src="prototype.js" type="text/javascript"></script>
  <script src="scriptaculous.js" type="text/javascript"></script>
</head>
<body>
<table border="0" cellapdding="10" cellspacing="0">
  <tr>
    <td valign="top" width="50%">
      < Div id="dropzone" style="border: thin solid rgb(0,0,0); height: 100; width: 100;"></div>
    </td>
    <td valign="top" width="50%">
      < Div id="sortlist" style="padding: 5px;">
        < Div id="name_kevin" style="border: thin solid rgb(0,0,0); padding: 3px;">kevin</div>
        < Div id="name_brady" style="border: thin solid rgb(0,0,0); padding: 3px;">brady</div>
        < Div id="name_catherine" style="border: thin solid rgb(0,0,0); padding: 3px;">catherine</div>
        < Div id="name_timothy" style="border: thin solid rgb(0,0,0); padding: 3px;">timothy</div>
      </div>
    </td>
  </tr>
</table>
<style type="text/css">
.hoveraction {
  background-color: #FFFFAA;
}
</style>
<script type="text/javascript">
  var people = ['kevin','brady','catherine','timothy'];
  function makesort() {
     Droppables.remove('dropzone');
    Sortable.create('dropzone', {tag: "div",
    //  Do something about the new sorted order (ie. ajax call)
    });
  }
  function makedrop() {
     Droppables.add('dropzone', {hoverclass: 'hoveraction', onDrop: function(element) {
      sortlist.removeChild(element);
       Dropzone.appendChild(element);
      makesort();
    }});
  }
  window.onload = function() {
    makesort();
    for ($i=0;$i<people.length;$i++) {
      var temp = 'name_' + people[$i];
      new  Draggable(temp,{revert:true,ghosting:true,onStart: function() { makedrop(); }});
    }
  }
</script>
</body>
</html>

posted by Kevin Marshall on 2008-03-05 00:00:00+00


Subscribe to my RSS feed »

BotFu feed with RSS reader

BotFu feed by Email


Search All Posts »


Kevin Marshall - Who's That?

I'm just your basic programmer. I can't spell to save my life, I'm not the greatest story teller, and I often ramble on about nothing. This blog showcases all of that!

If you're bored drop me an email at info at falicon.com or view my outdated resume.


Stalk Kevin on »

bit.ly
Delicious
Digg
Disqus
Facebook
Flickr
FriendFeed
Github
Last.fm
LinkedIn
StumbleUpon
Twitter (@falicon)

Archives by Category »

(28) Code »
(8) ColdFusion »
(15) Database »
(10) Factor »
(3) Falcons »
(321) General »
(13) JavaScript »
(18) Perl »
(17) PHP »
(20) Ruby »

Archives by Month »

(1) September 2010 »
(2) August 2010 »
(3) July 2010 »
(13) June 2010 »
(8) May 2010 »
(2) April 2010 »
(2) March 2010 »
(5) January 2010 »
(2) October 2009 »
(6) August 2009 »
(11) July 2009 »
(2) May 2009 »
(3) April 2009 »
(2) March 2009 »
(7) February 2009 »
(9) January 2009 »
(14) December 2008 »
(5) November 2008 »
(12) October 2008 »
(13) September 2008 »
(16) August 2008 »
(23) July 2008 »
(20) June 2008 »
(24) May 2008 »
(23) April 2008 »
(27) March 2008 »
(28) February 2008 »
(26) January 2008 »
(7) December 2007 »

Published Works »

Beginning Amazon's SimpleDB (Apress in dev.)
Pro Active Record (Apress 2007)
Web Services with Rails (O'Reilly 2006).

Contributed To »

Ruby Cookbook (O'Reilly 2006)
SQL Cookbook (O'Reilly 2005)
Various Reviews published in Computing Reviews

Free Code I've Created »

SimpleDB library in Python 3.0



This blog is powered by KickAssCode.