• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

JavaScript Arrays

 
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

I want to pass an Array consisting of emailIds into the request but I am not able of doing it.Can anyone help me in this?


 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You need to make a comma delimited string of the id's. You can only pass strings via a querystring, not objects.



 
Aalok Mishra
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

can you give a sample code for it so that I can take help from it?
 
Andy Crane
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It may work by just removing the brackets where you have concatenated it to the querystring.

Or use toString.

Then, there is an excellent chance that you're taking a comma delimited list of form values (native state) and creating an array so that you can create a comma delimited list of those same form values. (this is what it looks like to me) If this is the case, then you're using the id attribute incorrectly. An id should only be used one time on a web page. That why there is no: document.getElelementsById().

If the id's that you're calling in your code are referencing a collection of form fields, then you should be using the name attribute instead.
 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Another option is to use the javascript join() method. It takes all elements in the array and returns them as a concatenated string. The default separator is a comma, but the join method takes an optional separator argument as well. For instance, if you'd like to concatenate all your array elements with newlines between each elements, use myNewString = myArray.join('\r\n');
reply
    Bookmark Topic Watch Topic
  • New Topic