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 7862215
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T23:02:41+00:00 2026-06-02T23:02:41+00:00

Not sure if this is the correct title for this, so if its not

  • 0

Not sure if this is the correct title for this, so if its not then I am sorry. However, what I am attempting to do is this. Have an array that stores, Product Name, Price and Quantity. For multiple products that are entered using drop down boxes in HTML. Currently I have this.

var cart = new Object();

function main(uValue)
{
    //Get the value from the drop down
    var value = uValue.value;
    //Add on to the page the new value
    printOnPage(value);
    //Add 
    cart = addItem(value);
    printOnPage(cart);

}

function addItem(input)
{
    //cart.push(input);
    //return cart;

    //look up id in assoc. array
    //cart.numInCart++;
    cart.Amount = input;
    return cart;
}
function removeItem()
{
    cart.splice(1,1);
    return cart;
}

function printOnPage(input)
{
    var para = document.createElement("p");
    var paymentDiv = document.getElementById("payment");
    paymentDiv.appendChild(para);
    var txt = document.createTextNode(input);
    para.appendChild(txt);
}

And then this is the HTML that would relate to this.

<div class="item">
                <p>Faster than light car</p>
                <img src="i/toycar.jpg" width="85%" height="85%" alt="ToyCar" title="#WickCar">
                <p>Cost: £10 per item</p>

                <form name="form1" method="POST">
                    <select name="values" onchange="main(this)" >
                        <option value="1">1</option>
                        <option value="2">2</option>
                        <option value="3">3</option>
                        <option value="4">4</option>
                        <option value="5">5</option>
                        <option value="6">6</option>
                        <option value="7">7</option>
                        <option value="8">8</option>
                        <option value="9">9</option>
                    </select>
                </form>
            </div>

Ok, so a few questions. 1) am I going about this the correct way? 2) Why when I wish to view the content of the array do I get [object Object]
enter image description here

Is there a better way to do this?

Thanks, hope someone can enlighten me to this.

  • 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-06-02T23:02:45+00:00Added an answer on June 2, 2026 at 11:02 pm

    Change printOnPage(cart); to printOnPage(cart.Amount);

    It looks like you’re trying to output cart, which is an object, rather than one of the values for a key in cart.

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

Sidebar

Related Questions

Not sure what the correct title for this question should be. I have the
Context I'm trying to have some "plugins" (I'm not sure this is the correct
First off I'm not sure that's the proper title for this question but hopefully
Ok I'm not sure the title of this post is the correct way to
I'm still not sure this is the correct way to go about this, maybe
I'm not sure if this is the correct way to synchronize my ArrayList .
I'm not sure if this is the correct forum to ask this question so
This seems to be returning the correct answer, but I'm not sure if this
Not sure this is possible, but looking to write a script that would return
Ok, I'm not sure that my title was clear enough, but I will try

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.