Javascript program, if statement difficulties <p>this code does not work, at least not complete way it should. I'm trying to run it so an item is selected and then deposit amounts are chosen on the select menu until the proper amount is equaled or exceeded, resulting in change, but I cant seem to get my if statements to work properly. If anyone sees the problem, I would much appreciate the help.</p> <p><a href="http://jsfiddle.net/YgX4z/" rel="nofollow">http://jsfiddle.net/YgX4z/</a> </p> <pre><code>&lt;script type="text/javascript"&gt; var select; function changedepositedInput(objDropDown) { //console.log(parseFloat(objDropDown)); var objdeposited = document.getElementById("deposited"); objdeposited.value=parseFloat(objdeposited.value||'0'); var total=parseInt(objdeposited.value||'0'); objdeposited.value = parseFloat(objDropDown.value||'0')+total; var cost=parseInt('0'); var water = document.getElementById("water"); var soda = document.getElementById("soda"); var coffee = document.getElementById("coffee"); var beer = document.getElementById("beer"); if (water.checked) {cost=parseInt('75');} if (soda.checked) {cost=parseInt('150');} if (coffee.checked) {cost=parseInt('100');} if (beer.checked) {cost=parseInt('200');} if (total&gt;cost) { var change=document.getElementById("change"); change.value=total-cost; } else { var change=document.geElementById("change"); change.value="0"; } if (total&gt;=cost) { var objdelivered=document.getElementById("delivered"); objdelivered.value="Yes"; } else { var objdelivered=document.getElementById("delivered"); objdelivered.value="No"; } } &lt;/script&gt; &lt;h1&gt;Vending Machine Project&lt;/h1&gt; &lt;form name="vendingmachine" action=" "&gt; Choose Bevrage&lt;br&gt; &lt;input name="item" type="radio" id="water" checked="checked"&gt;Water 75 cents&lt;br&gt; &lt;input name="item" type="radio" id="soda"&gt;Soda $1.50&lt;br&gt; &lt;input name="item" type="radio" id="coffee"&gt;Coffee $1.00&lt;br&gt; &lt;input name="item" type="radio" id="beer"&gt;Beer $2.00&lt;br&gt; &lt;p&gt; &lt;label&gt;Deposit Money: &lt;select name="money" id="money" onchange="changedepositedInput(this)"&gt; &lt;option value="0"&gt;Choose Amount&lt;/option&gt; &lt;option value="10"&gt;10 cents&lt;/option&gt; &lt;option value="25"&gt;25 cents&lt;/option&gt; &lt;option value="50"&gt;50 cents&lt;/option&gt; &lt;option value="75"&gt;75 cents&lt;/option&gt; &lt;option value="100"&gt;$1.00&lt;/option&gt; &lt;/select&gt; &lt;/label&gt; &lt;/p&gt; &lt;p&gt;Total Deposited:&lt;input name="deposited" id="deposited" type="text" readonly="TRUE" value=""&gt;&lt;/p&gt; &lt;p&gt;Change Returned:&lt;input name="change" id="change" type="text" readonly="TRUE" value=" "&gt;&lt;/p&gt; &lt;p&gt;Bevrage Delivered:&lt;input name="delivered" id="delivered" type="text" readonly="TRUE" value=" "&gt;&lt;/p&gt; &lt;p&gt;&lt;input type="reset" value="Start Over"&gt;&lt;/p&gt; </code></pre> <p></p>