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]

Is there a better way to do this?
Thanks, hope someone can enlighten me to this.
var cart = new Object()gets you.