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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.