beaner_06 Posted February 4, 2010 Share Posted February 4, 2010 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> Link to comment https://forums.phpfreaks.com/topic/190976-hide-php-script-until-user-actually-submits-data/ Share on other sites More sharing options...
Mchl Posted February 4, 2010 Share Posted February 4, 2010 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>"; } Link to comment https://forums.phpfreaks.com/topic/190976-hide-php-script-until-user-actually-submits-data/#findComment-1007087 Share on other sites More sharing options...
beaner_06 Posted February 4, 2010 Author Share Posted February 4, 2010 Thank you. That worked. Link to comment https://forums.phpfreaks.com/topic/190976-hide-php-script-until-user-actually-submits-data/#findComment-1007088 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.