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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T11:10:33+00:00 2026-06-17T11:10:33+00:00

I made this simple shopping cart where you select quantity from a dropwdown list

  • 0

I made this simple shopping cart where you select quantity from a dropwdown list and these numbers get added and you get a total number for all the products and a total number for the product itself.

But i want it write the quantity with price and the name and write it in a div placed on the site so that it is easy for the user to see that he added a product. I made the calculating part by adding the products one by one, as i did not array them. But for this next part i just didn’t find a way that suited my needs. This is just from my test page , so i only have a few values , but in the other page i have over 70 listed just like these:

<div id="radioAlert">
<script type="text/javascript">
//calculator
function updatesum() {
document.form.sum.value =
(document.form.sum0.value -0) *99 +
(document.form.sum1.value -0) *99 +
(document.form.sum2.value -0) *99;

document.form.smu.value =
(document.form.prod0.value -0)*99  +
(document.form.prod1.value -0) *99 +
(document.form.prod2.value -0) *99 +
(document.form.prod3.value -0) *99 +
(document.form.prod4.value -0) *99;
document.form.totalsum.value =
(document.form.sum.value -0) +
(document.form.smu.value -0); //not a typo i was just lazy with the name

//arrays

//This one i did not get to work.
var myArray = newArray();
myArray[0]=document.form.sum2.value;
myArray[1]=document.form.prod0.value;
myArray[2]=document.form.prod1.value;
myArray[3]=document.form.prod2.value;
myArray[4]=document.form.prod3.value;
myArray[5]=document.form.prod4.value;

for (var i = 0; i < myArray.length; i++) {
        alert(myArray[i]);
}


//this part works but i want it to add its value only once and then replace its value if its updated again, if its 0 i want it to be completely removed.

var prod1 = document.form.sum2.value;
var prod2 = document.form.sum1.value;

var radioAlert = document.getElementById("radioAlert");
var radioAlert2 = document.getElementById("radioAlert"); 

if  (document.form.sum2.value>0) {
//document.write("pilotjakke pelsforet small  " +   prod1 + "  stk");
radioAlert.innerHTML += ("pilotjakke pelsforet small  " +   prod1 + "  stk");
alert("pilotjakke pelsforet medium  " +   prod1 + "  stk");
}

if  (document.form.sum1.value>0) {
//document.write("pilotjakke pelsforet small  " +   prod1 + "  stk");
radioAlert2.innerHTML += ("pilotjakke pelsforet medium  " +   prod2 + "  stk");

}
}
</script>
</div>

  • 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-17T11:10:35+00:00Added an answer on June 17, 2026 at 11:10 am

    There is no newArray function in JavaScript by default.

    Change

    var myArray = newArray();
    

    to

    var myArray = [];
    

    or

    var myArray = new Array();
    // Note space ---^
    

    The form using [] is generally preferred. In addition to being more concise, it’s not susceptible to someone redefining the Array constructor function.

    Note that you can initialize the array with the elements as well if you like:

    var myArray = [
        document.form.sum2.value,
        document.form.prod0.value,
        document.form.prod1.value,
        document.form.prod2.value,
        document.form.prod3.value,
        document.form.prod4.value
    ];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I made this simple function (remove all $elem from $array): function remall($array, $elem) {
i made this simple code to prevent hotlinking my files from my php download
I am teaching myself CUDA from the ground up. I made this simple kernel
I made this simple function to filter the data. I add the symbols that
I recently made this simple navigation where you have a couple links that have
I'm working on a bigger project atm, but I made this simple example to
So I made this (very simple) program with a swing GUI with NetBeans, and
This is simple text detection video made using an opencv. Any ideas how was
This module is part of a simple todo app I made with Python... def
i have made a simple php contact form following this tutorial: http://www.catswhocode.com/blog/how-to-create-a-built-in-contact-form-for-your-wordpress-theme The big

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.