On Feb 14, 2012, at 3:28 AM, Pankaj Sachan wrote:
> Hi All,
>
> I am very new in prototype.
>
> can you please help to make shuttle box (Dual list box).
AFAIK, there's nothing specific to this in Prototype. It's just JavaScript
array manipulation for the most part.
<select name="foo" id="foo" size="12">
<option value="One">One</option>
<option value="Two">Two</option>
<option value="Three">Three</option>
<option value="Four">Four</option>
</select>
<input type="submit" id="move" value="→"/>
<select name="bar" id="bar" size="12">
</select>
$('move').observe('click', function(evt){
evt.stop();
var foo = $('foo');
var bar = $('bar');
var choice = foo.options[foo.options.selectedIndex];
bar.options[bar.options.length] = new Option(choice.text, choice.value);
var newList = $A(foo.options).reject(function(opt){ return opt.selected
== true });
foo.options.length = 0;
newList.each(function(elm){
foo.options[foo.options.length] = new Option(elm.text,
elm.value);
});
});
Okay, I did use Array.reject() to filter the selected option out of the list,
and $() to get the references, and each to walk the array, but otherwise,
there's nothing here you couldn't do in vanilla JavaScript.
Walter
>
> Thanks & Regards
> Pankaj Singh
>
> --
> You received this message because you are subscribed to the Google Groups
> "Prototype & script.aculo.us" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/prototype-scriptaculous?hl=en.
>
--
You received this message because you are subscribed to the Google Groups
"Prototype & script.aculo.us" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/prototype-scriptaculous?hl=en.