Jump to content

Sum Help


toolman

Recommended Posts

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!

Link to comment
https://forums.phpfreaks.com/topic/270421-sum-help/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.