[jQuery] copy li values to an array

2008-02-04 Thread Paul Jones

I know the following would work if I wanted to copy the values of *each*
li
to a separate array element.

html
head
title/title

script type = text/javascript src=jquery.js/script

 script type = text/javascript
 var array1 = new Array() ;
 $(document).ready(function()
 {
 $('li').each(function(i) {  array1[i] = this.innerHTML )  })
 })
 /script

/head

body

ul
lia/li
lib/li
lic/li

lid/li
lie/li
lif/li

lig/li
lih/li
lii/li
/ul

/body

/html

However, I would like like to copy the *concatenated* values of each group
of
3 li's to 1 array element.
(eg) the 1st array element would have a value of 'abc', the 2nd array
element would have a value of 'def', and the 3rd array element would have a
value of 'ghi' etc.

What is the best way to do this?

TIA


[jQuery] nested function problem?

2007-12-02 Thread Paul Jones

I have managed to place the values of 4 textboxes into an array called
array1 (each value is placed into
its own array element).
I am having problems when I try to place the 1st 2 elements of array1
into the 1st element of array2
ie
array2[0] = concatenated value of array1[0] and array1[1]
array2[1] = concatenated value of array1[2] and array1[3]

I guess this isn't the optimum solution so any advice is welcome.

TIA

html
head
title/title
  script type = text/javascript src=jquery.js/script
  script type = text/javascript

  $(document).ready(function()
  {
  var array1 = new Array();
  var array2 = new Array();

$(#button).click(function ()
{
  $('.val').each(function(i)
  {
  array1[i] = $(this).val()   // this places the value of
each textbox into an array element
   alert(array1[i]) //- testing purposes - this works
  });
  // *PROBLEM AREA*
  // I would like (eg) element 1 of array2 to be the
concatenated value of element 1 and element 2 of array1
  // Pseudocode - array2[i] = array1[i] + array2[i + 1]
});
  });

 /script

/head

body

form
input type=text class=val value = 1
input type=text class=val value = 3 
input type=text class=val value = 5 
input type=text class=val value = 7 
input type=button id=button
/form

/body

/html