Calculating Form Fields PHP or JavaScript

Firstly the URL I posted and the associated pages are for testing purposes so please feel free to add entries so I can test your solution.
The URL with the start of what i am trying to work out is:
http://www.wholecaboodle.com.au/selectEvent.php
When you click 'Register" a page with a form will launch. At the bottom of the form the prices for member and non member tickets is displayed next to 2 text fields where the user will add the number of tickets required.
Below this is a total text field.
How do I auto total the No of member ticks x price + No of non-member ticks x price?
Please steer me towards a solution and whether it would be better to code this function in PHP or javaScript

Thanks

Best regards
laurence lewis

Lewilr9Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Loganathan NatarajanLAMP DeveloperCommented:
so, you want to display the "No of member ticks x price + No of non-member ticks x price" at the bottom...

then you could sum the rows of "No of member ticks x price"  "No of non-member ticks x price"

0
Loganathan NatarajanLAMP DeveloperCommented:
in the display record set processing itself have temp variable and calculate the sum values of both.. and assign to hidden variable or text field...

hope i am taking you the correct step
0
shiraztiCommented:
I'm not clear enough with your problem. Try this code........ maybe helpful to you
Anyway you need to perform a server validation once the form is submitted.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Test</title>
<script language="javascript">
 
var temp1 = 0;
var temp2 = 0;
 
	function doCalculate() {
		
		member = document.getElementById('noTicMem').value;
		nonmember = document.getElementById('noTicNon').value;
		
		
		if(member != '') { 
			member = member * 2;
			temp1 = member; 
		} else { temp1 = 0; }
		
		if(nonmember != '') { 
			nonmember = nonmember * 5;
			temp2 = nonmember; 
		} else { temp2 = 0; }
		
		var total = temp1 + temp2;
		document.getElementById('total').value = total;
	}
 
</script>
</head>
 
<body>
<form id="form1" name="form1" method="post" action="">
<p>noTicMem: <input type="text" name="noTicMem" id="noTicMem" onblur="doCalculate()" />
x2</p>
 
  
 
<p>noTicNonMem:
  <input type="text" name="noTicNon" id="noTicNon" onblur="doCalculate()" /> 
  x5
</p>
<p>Total:
  <input name="total" type="text" id="total" readonly="readonly" />
</p>
 
</form>
</body>
</html>

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.