Javascript onClick functions not working -


i've got money management system i'm trying write, , it's not working correctly. money printed in top right, when click on buttons change value, not work.

html:

<div id="content"> <div id="money_count">$$money$$</div> <br> <div id="items">     <table>         <tr>             <td><a href="#">$12.19</a>             </td>             <td><a href="#">$15.00</a>             </td>         </tr>         <tr>             <td><a href="#">$24.99</a>             </td>             <td><a href="#">$35.50</a>             </td>         </tr>     </table> </div> </div> 

css:

#content { font-family:helvetica; width:500px; box-shadow:0px 0px 10px 0px #aaa; top:30px; margin:0px auto; margin-top:40px; padding:10px 20px; border:dashed 2px #888; } #money_count {     color:#0f0;     padding:5px;     text-shadow:0px 0px 1px #333;     margin-right:0;     margin-left:auto;     margin-top:6px;     width:100px;     text-align:center; }  table, th td {     border:ridge 3px #aaa;     box-shadow:0px 0px 6px 0px #aaa; } table {     width:400px;     margin-left:50px;     margin-top:20px;     margin-bottom:50px; } td {     padding:4px;     background-color:#ccc;     text-align:center; } a, td {     color:black;     text-decoration:none;     width:auto;     height:100px; } 

javascript:

var money = 500.27 - 0.27; var moneyelement = document.getelementbyid("money_count"); moneyelement.innerhtml = money;  function updatemoney() {     moneyelement.innerhtml = money; }  function subtractmoney(amount) {     money -= amount;     updatemoney(); } 

any ideas why doesn't update money value in top right?

you need bind event listeners elements:

document.getelementbyid('button_id').addeventlistener('onclick', updatemoney, false)


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -