473,287 Members | 1,492 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,287 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 2365
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...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
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: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
1
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: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

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.