On Sep 18, 9:33 am, FrankTudor <[EMAIL PROTECTED]> wrote:
>                 var s = $('select').serializeArray(), t = [];
>                 $.each(s,function(n,v){ t[t.length]=v.value; });
>                 $('textarea').val(t.join('\n'));
>
> Hi I understand maybe 40 percent of the above code. Can someone
> explain it? What does the brackets mean the [] <<<< brackets.

Brackets are used in this context as an array literal:

var arrayVar = [];  //initialize arrayVar as an array.
     //  Cheaper/faster than var arrayVar = new Array();
var newVar = [1, 1, 2, 3, 5, 8];  //init array with values

> And can someone tell me what is happening in the
> $.each(s,function(n,v) <<<<<<< what's happening here.

$.each(obj, func)  applies func() to each obj.

http://docs.jquery.com/Core/each#callback
"Execute a function within the context of every matched element."

> also the t[t.length]=v.value; <<<< what is happening here.

Array.length is one more than the last index.  Thus,
     arrayVar[arrayVar.length] = val
has the effect as
     arrayVar.push(val)
(I.e., it appends an item onto the array.)

> and finally
> the t.join \n is that adding a carriage return or something?

array.join(joinChar) returns a string, with joinChar between each of
the elements.  E.g., arrayVar.join('\n') returns a string with each
element of arrayVar separated by a newline.

Cheers,
Pyro

> On Sep 18, 2:16 am, Wizzud <[EMAIL PROTECTED]> wrote:
>
> > This will put all selects (just selected values, no names) into textarea...
> >   var s = $('select').serializeArray(), t = [];
> >   $.each(s,function(n,v){ t[t.length]=v.value; });
> >   $('textarea').val(t.join('\n'));
>
> > FrankTudor wrote:
>
> > > Hi all,
>
> > > I am creating a little tool that has two multiple select boxes and
> > > then a text area.  I need to figure out how to take the selected
> > > conets of one box, or the other, or both and pop them to the textarea.
>
> > > If there are no examples can someone tell me what dom or events I need
> > > to be looking at?
>
> > --
> > View this message in 
> > context:http://www.nabble.com/multiple-select-box-to-textarea-tf4469504s15494...
> > Sent from the JQuery mailing list archive at Nabble.com.

Reply via email to