Jump to content

Hide PHP script until user actually submits data


beaner_06

Recommended Posts

Hello, I have attached my code. How would I delay the message: "Your Commission is: $_____" until the user actually enters an amount and hits the 'Show Commission' button? Thanks in advance.

 

<!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>
    <title>Commission</title>
</head>
<body>

<h1>Commission Computation</h1>

<form method="get" action='rlbSingleGet.php'>
Monthy Sale: <input name='sale' type='text' />
	<br />
	<br />
Select your Sales Region:
	<select name='Region' size='4' style='height:38px;'>
		<option name='eastern'>Eastern</option>
		<option name='western'>Western</option>
	</select>
	<br />
	<br />
	<input type='submit' value='Show Commission'/>
</form>

<?php
		$strSale = $_GET["sale"];
		$lboRegion = $_GET["Region"];

		//Depending on region will decide amount of commission that person receives

		switch ($lboRegion)
		{
			Case "Eastern":
				$commission = $strSale * 0.1;
				break;
			Case "Western":
				$commission = $strSale * 0.2;
				break;
		}

		echo "<h2>Your Commission is: ";
		// The following lines are only for documenting the PHP number_format and money_format
		// functions that do not work in Windows.  To display money formatted values in Windows and PHP,
		// we will have to use the following type of code:
		setlocale(LC_ALL, ''); // Locale will be different on each system.
		$locale = localeconv();
		echo $locale['currency_symbol'], number_format($commission, 2, $locale['decimal_point'], $locale['thousands_sep']);
		echo "</h2>";
?>

</body>
</html>

if(isset($strSale)) {
  echo "<h2>Your Commission is: ";
  setlocale(LC_ALL, ''); // Locale will be different on each system.
  $locale = localeconv();
  echo $locale['currency_symbol'], number_format($commission, 2, $locale['decimal_point'], $locale['thousands_sep']);
  echo "</h2>";
}

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.