Page 1 of 1

Hide PHP script until User Submits Data

Posted: Thu Feb 04, 2010 4:22 pm
by beaner_06
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.

Code: Select all

 
<!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>
 

Re: Hide PHP script until User Submits Data

Posted: Thu Feb 04, 2010 4:41 pm
by beaner_06
Nevermind. I figured it out.