Results 1 to 4 of 4

Thread: help with php form please ?

  1. #1
    Join Date
    Oct 2011
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy help with php form please ?

    hi there
    plz could someone assist me to show the "test property / value" of the "Duration field. at the moment, once the data is submitted - it shows:
    "Duration: 200.00" instead of "Duration: Full Day - R200.00

    please can someone help?
    This is the code:

    Code:
    <?php if(isset($_POST['action']) && $_POST['action'] == "submit_post"): ?>
    
    <?php
        $string = "Customer Name: ". $_POST['name']. "\n";
        $string .= "Company: ". $_POST['company']. "\n";
        $string .= "Conference Name: ". $_POST['field-36b58f8c5142ff3']. "\n";
        $string .= "Telephone Number: ". $_POST['field-7c496d0fb21abfd']. "\n";
        $string .= "Duration: ". $_POST['field-385963a5c9a4ef9']. "\n";
        $string .= "Date Of Conference: ".$_POST['field-date1']. "\n";
        $string .= "Number of People: ". $_POST['field-5af722f60ee2f9b']. "\n";
        $string .= "Menu: ". $_POST['menu']. "\n";
        $string .= "Overhead Projector: ". $_POST['field-73cf21adf8b52d5']. "\n";
        $string .= "Email: ". $_POST['field-3f92f5a7876cd50']. "\n";
        $string .= "Sub Total: ". $_POST['totalcost']. "\n";
    
        print "<p>". nl2br($string) ."</p>";
    
        $to = $_POST['field-3f92f5a7876cd50'] . ", "; //This is the users email address
        $to .= "melissafleetwood@yahoo.com" . ", "; //Put your first email here
        $to .= "airport.game.lodge@teleguid.co.za"; //Put your second email here
    
        $subject = "Reciept confirmation";
        $headers = "From: Airport Game Lodge";
    
        mail($to, $subject, $string, $headers);
    ?>
    
    <?php else: ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html>
    <head>
    <title>Contact Form Test</title>
    </head>
    <body>
    <form action="" method="post">
    <div>
    <input type="hidden" name="action" id="acctid" value="submit_post" />
    </div>
    <table cellspacing="5" cellpadding="5" border="0">
    <td valign="top">
    <strong>Name of Contact Person:</strong>
    </td>
    <td valign="top">
    <input type="text" name="name" id="name" size="40" value="" />
    </td>
    </tr>
    <tr>
    <td valign="top">
    <strong>Company:</strong>
    </td>
    <td valign="top">
    <input type="text" name="company" id="company" size="40" value="" />
    
    </td>
    </tr>
    <tr>
    <td valign="top">
    <strong>Official Name Of Conference</strong>
    </td>
    <td valign="top">
    <input type="text" name="field-36b58f8c5142ff3" id="field-36b58f8c5142ff3" size="40" value="" />
    
    </td>
    </tr>
    <tr>
    <td valign="top">
    <strong>Tel No Of Contact Person:</strong>
    </td>
    <td valign="top">
    <input type="text" name="field-7c496d0fb21abfd" id="field-7c496d0fb21abfd" size="30" value="" />
    
    </td>
    </tr>
    <tr>
    <td valign="top">
    <strong>Duration:</strong>
    </td>
    <td valign="top">
    <input type="radio" name="field-385963a5c9a4ef9" id="game4" value="220.00" onclick="UpdateCost()"> Full Day R220.00<br/>
    <input type="radio" name="field-385963a5c9a4ef9" id="game5" value="200.00" onclick="UpdateCost()"> Half Day R200.00<br/>
    </td>
    </tr>
    <tr>
    <td valign="top">
    <strong>Date Of Conference:</strong>
    </td>
    <td valign="top">
    <input type="text" name="field-date1" id="field-date1" autocomplete="off" size="10" value="" 
    </td>
    </tr>
    <tr>
    <td valign="top">
    <strong>No Of People</strong>
    </td>
    <td valign="top">
    <input type="text" name="field-5af722f60ee2f9b" id="field-5af722f60ee2f9b" size="10" value="" onchange="UpdateCost()"/>
    
    </td>
    </tr>
    <tr>
    <td valign="top">
    <strong>Please select a menu:</strong>
    </td>
    
    <td valign="top">
    <input type="radio" name="menu" id='game0' value="60.00" onclick="UpdateCost()">Menu A (60.00)<br>
    <input type="radio" name="menu" id='game1' value="90.00" onclick="UpdateCost()">Menu B (90.00)<br>
    <input type="radio" name="menu" id='game2' value="120.00" onclick="UpdateCost()">Menu C (120.00)<br>
    <input type="radio" name="menu" id='game3' value="150.00" onclick="UpdateCost()">Braai/Barbeque (150.00)<br>
    
    </td>
    </tr>
    <tr>
    <td valign="top">
    <strong>Overhead Projector</strong>
    </td>
    <td valign="top">
    <input type="checkbox" name="field-73cf21adf8b52d5" id="game6" value="650.00" onclick="UpdateCost()">R650.00 <br/>
    
    </td>
    </tr>
    <tr>
    <td valign="top">
    <strong>Email of Contact Person: </strong>
    </td>
    <td valign="top">
    <input type="text" name="field-3f92f5a7876cd50" id="field-3f92f5a7876cd50" size="30" value="" />
    
    </td>
    
    <tr>
    <td valign="top">
    <strong>Sub Total: </strong>
    </td>
    <td valigh="top">
    <input type="text" id="totalcost" name="totalcost" size="10" value="">
    
    </td>
    
    <tr>
    
    <td colspan="2" align="center">
    <input type="submit" value=" Submit Form " />
    </td>
    
    </tr>
    
    </form>
    
    <script type="text/javascript">
    function UpdateCost() {
    var sum = 0;
    var gn, elem, totalAmmount, peopleNum;
    for (i=0; i<7; i++) {
    gn = 'game'+i;
    if(gn != 'game6'){
    elem = document.getElementById(gn);
    if (elem.checked == true) { sum += Number(elem.value); }
    }
    peopleNum = document.getElementById('field-5af722f60ee2f9b').value;
    if(isNaN(peopleNum ) || peopleNum==''){
    totalAmmount = sum;
    }
    else{
    totalAmmount = sum * peopleNum;
    }
    }
    if(document.getElementById('game6').checked == true)
    {
    totalAmmount += Number(document.getElementById('game6').value);
    }
    document.getElementById('totalcost').value = totalAmmount.toFixed(2);
    }
    </script>
    
    <script type="text/javascript">
    var value="";
    var numPeople=document.getElementById("field-5af722f60ee2f9b")
    numPeople.onkeydown=function(e){
        value = this.value + e;
    }
    
    numPeople.onkeyup=function(e) {
    this.value=this.value.replace(/[^\d]/,'');
        if(this.value != value) {
            UpdateCost();
        }
    }
    </script>
    
    </body>
    </html>
    <?php endif; ?>

    Code:
    /* This script and many more are available free online at The JavaScript Source!! http://javascript.internet.com Created by: Jay Rumsey | http://www.nova.edu/~rumsey/ */
    
    function UpdateCost() {
    var sum = 0;
    var gn, elem, totalAmmount, peopleNum;
    for (i=0; i<7; i++) {
    gn = 'game'+i;
    if(gn != 'game6'){
    elem = document.getElementById(gn);
    if (elem.checked == true) { sum += Number(elem.value); }
    }
    peopleNum = document.getElementById('field-5af722f60ee2f9b').value;
    if(isNaN(peopleNum ) || peopleNum==''){
    totalAmmount = sum;
    }
    else{
    totalAmmount = sum * peopleNum;
    }
    }
    if(document.getElementById('game6').checked == true)
    {
    totalAmmount += Number(document.getElementById('game6').value);
    }
    document.getElementById('totalcost').value = totalAmmount.toFixed(2);
    }

  2. #2
    Join Date
    Nov 2011
    Location
    Buenos Aires
    Posts
    15
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default

    You could concat it:
    "Full Day - R".$_POST['field-385963a5c9a4ef9']

  3. #3
    Join Date
    Oct 2011
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    hi there
    Thank you so much
    However, It is now showing "Full Day - R200.00" which is great, but how can I make it show either "Full Day" or "Half Day" (it depends on the selection made by the user)

    THank you so much

  4. #4
    Join Date
    Nov 2011
    Location
    Buenos Aires
    Posts
    15
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default

    You could crate a hidden texbox and in your update cost fuction update the field document.getElementById('HIDDENDAY').value="HALF"

    etc etc
    Or
    you could make:
    If($_POST['field-385963a5c9a4ef9']==200)
    {
    $type_day="HALF";
    } else { $type_day="FULL";}

    string.=$type_day." - R".$_POST['field-385963a5c9a4ef9']

    There are a couple of more solution but these are just an example

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •