html/ javascript shop

by tmanrocks994   Last Updated June 13, 2019 03:13 AM

Im new to drop down menus. How can I make a working shop in html/javascript. I have this so far . I want help with the selling of a material part. i know i should use if statements but im not sure how to format the function . I want if bronze is selected for how much you can sell it for to be displayed. then if u press sell button you gain that much gold then lose 1 bronze.

var goldcoins = 0;
var goldcoins = 0;
var Bronzeprice = 10;
var Silverprice = 20;
var GoldPrice = 50;
var DiamondPrice = 100;
var ShrimpPrice = 10;
var BassPrice = 20;
var SalmonPrice = 50;
var SharkPrice = 100;

function sellItem(){
    var mylist=document.getElementById("myList");document.getElementById("favorite").value=mylist.options[mylist.selectedIndex].text;}

Html code:

                   <font size="+2"><b>Shop</b>
                       <br />
                      <font size="+0"> Auto Miner <button 
    id="MinerCostBtn" >Buy</button>
                    <br />
                  <font size="+0"> Auto Fisher <button onclick="buyFisher()" id="FisherCostBtn" >Buy</button>
                <br />
                <br />
                <select id"SellBox" >
                    <option> Bronze </option>
                    <option> Silver </option>
                    <option> Gold </option>
                    <option> Diamond </option>
                    <option> Shrimp </option>
                    <option> Bass </option>
                    <option> Salmon </option>
                    <option> Shark </option>
                    For:&nbsp;<span id="currentPrice">0</span> &nbsp;<button onclick="SellItem()" id="SellBtn" >Sell</button>

                  <br />
                  Gold Coins: <span id="goldcoins">0</span>
                  <br />
                  Buy skillpoint 100,000 gold <button onclick="buySkillPoint()" id="SkillPointBtn" >Buy</button>
                  <br />
                  Buy diamond 10,000 gold <button onclick="buyDiamond()" id="diamonddBtn" >Buy</button>
                  <br />
                  Buy shark 10,000 gold <button onclick="buyShark()" id="sharkkBtn" >Buy</button>
                  <br />
                  <br />
                  <br />

I expect when bronze is selected (etc) for how much you will gain from it to be displayed then when button is pressed for you to lose 1 bronze and gain that amount of gold. While the drop down menu is on that item. I have the variables on a diffrent javascript . i do that all those drop down button items . I just need to know how to format the funtion so if they are selected in the drop down menu that item will sell.

Tags : javascript html

Related Questions

Updated December 24, 2016 07:36 AM

Updated May 07, 2018 02:13 AM

Updated March 17, 2017 16:13 PM

Updated June 30, 2015 13:05 PM

Updated April 27, 2018 18:13 PM