473,326 Members | 2,110 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Moving all items from one Scriptaculous box to another

I am using Thomas Fuchs's amazing drag-and-drop JavaScript library
available at:

http://wiki.script.aculo.us/scriptac...ow/DragAndDrop

to allow the user to select a subset of items listed in one box by
dragging them to another and sort them in the latter, and it works
a treat.

However, I'd now like to add a couple of buttons, "<<" and ">>" between
the pair of boxes so that the user can shuffle all the items from one
box
to the other and back again in a single click.

But I'm eternally ***ed if I can get the code to work, even after
spending
three hours on it, and was wondering if an expert might spot something
obvious or even have done the same thing. Anyway, the relevant code
is as follows:

(in page header ..)

<script src="js/prototype.js" type="text/javascript"></script>
<script src="js/scriptaculous.js" type="text/javascript"></script>

<script type="text/javascript">
// <![CDATA[

function spt_form_submit()
{
document.spt_main_form.spts.value=
Sortable.sequence("secondlist").join("' . '_' . '");

return true;
}

// ]]>
</script>';
(Following defines the two boxes, selectable ("firstlist") and selected
("secondlist")
with the two buttons between them:

* "choose_none" that is supposed to shuffle every item back to the
"selectable" list and empty the "selected" list

* "choose_all' that is supposed to do the opposite. Currently
"choose_all"
has only a JavaScript stub, until I can get the "choose_none" button
working! )
<table width="800px">

<tr><td width="40%"><h3 style="text-align:center">Selectable Items</h3>

<ul class="sortabledemo" id="firstlist" style="height:200px;
margin:2px; overflow:auto; border:1px solid black;"><li id="id_1">Item
1</li>;"><li id="id_2">Item 2</li> .. </ul></td>
<td width="20%"><center><table>
<tr><td><input type="submit" name="choose_none" value="&lt;&lt;"
onClick="' .

flist = document.getElementById(\'firstlist\');
slist = document.getElementById(\'secondlist\');

var flth = flist.length;
var slth = slist.length;

for (var i = 0; i < slth; i++)
{
flist.appendChild(slist.options.item[i]);
}

slist.length = 0;

Sortable.destroy(\'firstlist\');
Sortable.destroy(\'secondlist\');

Sortable.create(\'firstlist\',

{dropOnEmpty:true,containment:[\'firstlist\',\'secondlist\'],constraint:false});
Sortable.create(\'secondlist\',

{dropOnEmpty:true,handle:\'handle\',containment:[\'firstlist\',\'secondlist\'],constraint:false});'
..
'return false;"></td></tr>
<tr><td>&nbsp</td></tr>
<tr><td><input type="submit" name="choose_all" value="&gt;&gt;"
onClick="return false;"></td></tr>
</table></center></td>
<td width="40%"><h3 style="text-align:center">Selected Items</h3>
<ul class="sortabledemo" id="secondlist" style="height:200px;
margin:auto; overflow:auto; border:1px solid black;"></ul></td></tr>

</table>

<script type="text/javascript">
// <![CDATA[
Sortable.create("firstlist",

{dropOnEmpty:true,containment:["firstlist","secondlist"],constraint:false});
Sortable.create("secondlist",

{dropOnEmpty:true,handle:\'handle\',containment:["firstlist","secondlist"],constraint:false});
// ]]>
</script>';
I think that should be enough to give a reasonable idea of what I'm
trying
to achieve, and if anyone has any thoughts or obvious (or what should
be obvious!) observations, I'll be very interested.

Note that I've plugged a couple of variable values with hard-coded
text,
to make the sample easier to follow. So don't worry about minor syntax
errors - I think my problems go somewhat deeper than that!

Cheers

John Ramsden

Mar 27 '06 #1
1 2367
I've had luck asking about Scriptaculous on
ra************@lists.rubyonrails.org

Signup for the list

http://lists.rubyonrails.org/mailman...rails-spinoffs

- Peter

Mar 27 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Kay | last post by:
Hello, I have two list boxes on my form, one initially displays with items and the other displays blank, by clicking a button, it is possible to move items from one box to another and vice a...
2
by: Jake Barnes | last post by:
I've read over the documentation for these effects: http://wiki.script.aculo.us/scriptaculous/show/CombinationEffectsDemo I want to include them on my page. I tried attaching using onload, but...
1
by: =?Utf-8?B?SmVmZiBUdQ==?= | last post by:
Hi, I'm using two menu controls. One is displayed at the top of the page. The other menu is displayed on the left side using a single site map. The top menu is for displaying level 1. The left...
2
by: darrel | last post by:
I've been working on a side project off and on (more off than on) for a year or so. Overtime, it's become a bit of a frankenstein. It uses the Scriptaculous javascript library for a lot of...
3
by: libsfan01 | last post by:
hi i have a page which contains an visible nav down the left-hand side. when you click a button it needs to appear. i thought it would be cool to use scriptaculous to make it slide down. can...
4
by: HMS Surprise | last post by:
Just wondered if there was some python idiom for moving a few items from one list to another. I often need to delete 2 or 3 items from one list and put them in another. Delete doesn't seem to have...
3
by: Brian Simmons | last post by:
Hi All, I search on codeproject and google but didn't find what I was looking for. Anybody know of a good implementation where you have 2 listboxes and you want to move items between the 2. ...
0
by: linkswanted | last post by:
We are your trusted source. World Moving & Storage is bonded and licensed by the U.S. Department of Transportation and is one of the largest residential moving and corporate relocation company in...
0
by: linkswanted | last post by:
We are your trusted source. World Moving & Storage is bonded and licensed by the U.S. Department of Transportation and is one of the largest residential moving and corporate relocation company in...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.