toolman Posted November 7, 2012 Share Posted November 7, 2012 Hi, I have this script which adds up various options in some drop down menus. However, if I select/keeps selecting an option, it add it to the total each time I select it. Is there a way I can have it so it it only adds it on once and to use an either/or method - so only one value will be added? var sum =499; var count=0; var output; function UpdateCost() { var i = document.getElementById('graphic'); sum = sum + parseFloat(document.getElementById('graphic').value); document.getElementById('result').value = sum; } function UpdateCost2() { var i = document.getElementById('transit'); sum = sum + parseFloat(document.getElementById('transit').value) ; document.getElementById('result').value = sum; } function UpdateCost3() { var i = document.getElementById('lights'); sum = sum + parseFloat(document.getElementById('lights').value) ; document.getElementById('result').value = sum; } function UpdateCost4() { var i = document.getElementById('wooden'); sum = sum + parseFloat(document.getElementById('wooden').value) ; document.getElementById('result').value = sum; } function UpdateCost5() { var i = document.getElementById('case'); sum = sum + parseFloat(document.getElementById('case').value) ; document.getElementById('result').value = sum; } Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/270421-sum-help/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.