Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1069365
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T20:24:47+00:00 2026-05-16T20:24:47+00:00

How is it possible to enable the following JavaScript function, sending a POST request,

  • 0

How is it possible to enable the following JavaScript function, sending a POST request, to recieve productID parameter not as a single string variable but as a collection of productID‘s?

i.e. to get in output a string like:

“productId=126504&productId=126505&productId=126506&productId=126507&productId=126508”

 <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
 <script type="text/javascript">
 function addToCart(productId, returnUrl) {
    var form = $(document.createElement('form'))
    .attr('action', '/products/addtocart')
    .attr('method', 'post')
    .append(
        $(document.createElement('input'))
            .attr('type', 'hidden')
            .attr('name', 'productId')
            .val(productId)
    )
    .append(
        $(document.createElement('input'))
            .attr('type', 'hidden')
            .attr('name', 'returnUrl')
            .val(returnUrl)
    );
    $('body').append(form);
    form.submit();
}
</script>

Edit:

Just to be more clear:
When calling this function with a parameter 126504 the function outputs productId=126504. How to pass multiple productID’s 126504,126505,126506,126507,126508 in order to get the function output 126504&productId=126505&productId=126506&productId=126507&productId=126508 ?

I call the function from a Silverlight app:

 HtmlPage.Window.Invoke("addToCart", "126504", "http://localhost:10930/Products");
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T20:24:47+00:00Added an answer on May 16, 2026 at 8:24 pm

    Add multiple input items with the same name on the same form, and you should get exactly what you’re looking for.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: How to use enable_if to enable member functions based on template parameter
I'm using JavaScript to enable/disable stylesheets using the following: document.styleSheets[0].disabled = true|false; This JS
Javascript containing errors sometimes does not execute without any error message. The following line
Possible Duplicate: How can I code a C# function to accept a variable number
Anyone know if its possible to enable horizontal scrolling ONLY in a windows forms
In bash, I believe it is possible to enable tab completion on the terminal
Is it possible to programmatically enable Desktop Sync for a folder via the Box.com
Possible Duplicate: How can I disable/enable UISearchBar keyboard's Search button? Can we disable the
Is it possible to disable or enable subgrid based on the selected value when
It's possible to implement INotifyCollectionChanged or other interface like IObservable to enable to bind

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.