Jump to content

Auto Sum Order Form total.


samf_20

Recommended Posts

Hi,

 

Im currently creating a Order form and everything works fine except the Order total I got. Currently it does work but not properly and I cannot figure out how to fix the issue.

 

Basically I got 4 checkboxes with 4 seperate values. For example I would select one checkbox and the order total box will display £55. Then I would de-select it and it would display £0. But, if i select another box whilst another checkbox is selected it will add the new checkboxes values onto the previous value where is shouldnt write on top it should overwrite it. I got some java script so my fourth checkbox can be selected with any of the other 3 but only one of the other 3 can be selected at a time.

 

The javascript is:

function UpdateCost(ev) {
    var sum = Number(document.getElementById('totalcost').value);
    if (ev.checked){
        sum += Number(ev.value);
	document.getElementById('totalcost').value = sum.toFixed(2);
    }
    else{
        sum -= Number(ev.value);
    }
    document.getElementById('totalcost').value = sum.toFixed(2);
}

 

My HTML is:

 

<input name="registrationday1" type="checkbox" id="registrationday1" value="55.00" onClick="CheckRegistrationDaysBothOption();DisplayconfPay1();UpdateCost(this);"> 

                            <input type="checkbox" name="registrationday2" id="registrationday2" value="55.00" onClick="CheckRegistrationDaysBothOption();DisplayconfPay2();UpdateCost(this);">

<input name="registrationday3" type="checkbox" id="registrationday3" value="100.00" onClick="CheckRegistration56Days();DisplayconfPay3();UpdateCost(this);">

                          <input type="checkbox" name="fifthDecCheckBox" id="fifthDecCheckBox" value="55.00" onClick="DisplayfifthDecPanel();UpdateCost(this);">

 

Also this is the javascript I use to un-check my checkboxes:

 

		function CheckRegistration56Days()
	{
		var day1 = document.getElementById('registrationday1');
		var day2 = document.getElementById('registrationday2');
		var day3 = document.getElementById('registrationday3');

		if(day3.checked)
		{
			day2.checked = false;
			day1.checked = false;
		}
		else if(!day3.checked)
		{
			day2.checked = false;
			day1.checked = false;
		}
	}

	function CheckRegistrationDaysBothOption()
	{
		var day1 = document.getElementById('registrationday1');
		var day2 = document.getElementById('registrationday2');
		var day3 = document.getElementById('registrationday3');

		if(day2.checked)
		{
			day1.checked = false;
			day3.checked = false;
		}
		else if(!day2.checked)
		{
			day3.checked = false;
		}
	}

 

Thanks, any help will be appreciated.

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.