Just considering the problem area, and assuming that you want a
generic solution...

for(var i = 0; i<array1.length; i+=2){
  array2.push(array1[i] + (array1[i+1] || ''));
}

On Dec 3, 7:30 am, "Paul Jones" <[EMAIL PROTECTED]> wrote:
> 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>

Reply via email to