Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

Help with HTML/ Javascript total sales calculator?

for some reason my calculator isnt working and i dont know why i was hoping someone could help me.

<html>

<head>

<style> body {background-color:yellow}

</style>

<title>Paralax Motors Corps. </title>

</head>

<body>

<h1> Paralax Motors Corps. </h1>

<br>

<h2> Sales ($ Millions) </h2>

<br>

<!-- note to self use tag p instead of double br to break up lines -->

Eastern Division<input type="text" id="Eastern" onchange=''>

<br><br>

Western Division<input type="text" id="Western" onchange=''>

<br><br>

<button id="Total Sales" onclick='

var total_2017 = Number(Eastern.value) + Number(Western.value); sales2017.value = total_2017;'>Calculate Total</button>

<br><br>

2017 Total Sales<input type="text" id="sales2017" onchange=''>

<br><br>

Estimate for 2018

<input type="radio" name="estimate" id="high" onclick='var high_increase=0.30;

var high_sales = sales2017.value*(1+high_increase) ; 2018sale.value = high_sales;'>high

<input type="radio" name="estimate" id="low" onclick='

var low_increase=0.10 ;

var low_sales = sales2017.value*(1+low_increase) ; 2018sale.value= low_sales ; '>low

<br><br>

2018 Expected Sales<input type="text" id="2018sale" onchange=''>

</body>

</html>

Attachment image

2 Answers

Relevance
  • Anonymous
    3 years ago
    Favorite Answer

    try this... only needs to change 3 lines.

    Eastern Division<input type="text" id="Eastern">

    Western Division<input type="text" id="Western">

    <button id="Total Sales" onclick='sales2017.value = Number(Eastern.value) + Number(Western.value)'>Calculate Total</button>

    2017 Total Sales<input type="text" id="sales2017">

    Estimate for 2018

    <input type="radio" name="estimate" id="high" onclick='2018sales.value = Number(sales2017.value) * (1.3)'>high

    <input type="radio" name="estimate" id="low" onclick='2018sales.value = Number(sales2017.value) * (1.1)'>low

    2018 Expected Sales<input type="text" id="2018sales">

  • Chris
    Lv 7
    3 years ago

    You can't use 2018sales as identifier in JS code. Variables cannot start with numeric characters.

    Fixed: https://jsfiddle.net/og7ewmof/

Still have questions? Get your answers by asking now.