www.webdeveloper.com
Page 2 of 3 FirstFirst 123 LastLast
Results 16 to 30 of 33

Thread: dynamically calculate the sum of fields

  1. #16
    Join Date
    Mar 2009
    Posts
    452
    well that's not a thing to worry about. however you can search on net about PHP Notice: Undefined Variable

    add error_reporting(E_ALL ^ E_NOTICE); as a first statement in your php file and try again.

  2. #17
    Join Date
    Oct 2012
    Posts
    24
    Thanks for the replies guys.
    I've added error_reporting(E_ALL ^ E_NOTICE); into the php file but it now doesn't report anything in the log file (but still errors on the front end) so i took it out again.

    Below is the code in play.

    PHP:
    Code:
    <?php
    //set database variables
        $host="localhost";
        $user="test";
        $password="user";
        $database="test";
        
        //connect to the database
        mysql_connect($host, $user, $password) or die(mysql_error());
        mysql_select_db($database) or die(mysql_error());
        
        
    //Check to see if the checkboxes are ticked or unticked
    $MonCheck = isset($_POST['MonCheck']) ? 1 : 0;
    $TueCheck = isset($_POST['TueCheck']) ? 1 : 0;
    $WedCheck = isset($_POST['WedCheck']) ? 1 : 0;
    $ThuCheck = isset($_POST['ThuCheck']) ? 1 : 0;
    $FriCheck = isset($_POST['FriCheck']) ? 1 : 0;
    $SatCheck = isset($_POST['SatCheck']) ? 1 : 0;
    $SunCheck = isset($_POST['SunCheck']) ? 1 : 0;
    $MonMealCheck = isset($_POST['MonMealCheck']) ? 1 : 0;
    $TueMealCheck = isset($_POST['TueMealCheck']) ? 1 : 0;
    $WedMealCheck = isset($_POST['WedMealCheck']) ? 1 : 0;
    $ThuMealCheck = isset($_POST['ThuMealCheck']) ? 1 : 0;
    $FriMealCheck = isset($_POST['FriMealCheck']) ? 1 : 0;
    $SatMealCheck = isset($_POST['SatMealCheck']) ? 1 : 0;
    $SunMealCheck = isset($_POST['SunMealCheck']) ? 1 : 0;
    $MonEveningMealCheck = isset($_POST['MonEveningMealCheck']) ? 1 : 0;
    $TueEveningMealCheck = isset($_POST['TueEveningMealCheck']) ? 1 : 0;
    $WedEveningMealCheck = isset($_POST['WedEveningMealCheck']) ? 1 : 0;
    $ThuEveningMealCheck = isset($_POST['ThuEveningMealCheck']) ? 1 : 0;
    $FriEveningMealCheck = isset($_POST['FriEveningMealCheck']) ? 1 : 0;
    $SatEveningMealCheck = isset($_POST['SatEveningMealCheck']) ? 1 : 0;
    $SunEveningMealCheck = isset($_POST['SunEveningMealCheck']) ? 1 : 0;
    $MonOvernightCheck = isset($_POST['MonOvernightCheck']) ? 1 : 0;
    $TueOvernightCheck = isset($_POST['TueOvernightCheck']) ? 1 : 0;
    $WedOvernightCheck = isset($_POST['WedOvernightCheck']) ? 1 : 0;
    $ThuOvernightCheck = isset($_POST['ThuOvernightCheck']) ? 1 : 0;
    $FriOvernightCheck = isset($_POST['FriOvernightCheck']) ? 1 : 0;
    $SatOvernightCheck = isset($_POST['SatOvernightCheck']) ? 1 : 0;
    $SunOvernightCheck = isset($_POST['SunOvernightCheck']) ? 1 : 0;
    //insert data from form
                $insert="INSERT INTO mileageform 
                (EmployeeName,EmployeeRef,WeeksPerYear,MonTownFrom,MonPostcodeFrom,MonTownTo,MonPostcodeTo,MonMiles,TueTownFrom,TuePostcodeFrom,TueTownTo,TuePostcodeTo,TueMiles,WedTownFrom,WedPostcodeFrom,WedTownTo,WedPostcodeTo,WedMiles,ThuTownFrom,ThuPostcodeFrom,ThuTownTo,ThuPostcodeTo,ThuMiles,FriTownFrom,FriPostcodeFrom,FriTownTo,FriPostcodeTo,FriMiles,SatTownFrom,SatPostcodeFrom,SatTownTo,SatPostcodeTo,SatMiles,SunTownFrom,SunPostcodeFrom,SunTownTo,SunPostcodeTo,SunMiles,SumMiles,MonCheck,TueCheck,WedCheck,ThuCheck,FriCheck,SatCheck,SunCheck,MonHours,TueHours,WedHours,ThuHours,FriHours,SatHours,SunHours,SumHours,MonTravel,TueTravel,WedTravel,ThuTravel,FriTravel,SatTravel,SunTravel,MonMealCheck,TueMealCheck,WedMealCheck,ThuMealCheck,FriMealCheck,SatMealCheck,SunMealCheck,MonEveningMealCheck,TueEveningMealCheck,WedEveningMealCheck,ThuEveningMealCheck,FriEveningMealCheck,SatEveningMealCheck,SunEveningMealCheck,MonOvernightCheck,TueOvernightCheck,WedOvernightCheck,ThuOvernightCheck,FriOvernightCheck,SatOvernightCheck,SunOvernightCheck) 
                VALUES ('$EmployeeName','$EmployeeRef,'$WeeksPerYear','$MonTownFrom','$MonPostcodeFrom','$MonTownTo','$MonPostcodeTo','$MonMiles','$TueTownFrom','$TuePostcodeFrom','$TueTownTo','$TuePostcodeTo','$TueMiles','$WedTownFrom','$WedPostcodeFrom','$WedTownTo','$WedPostcodeTo','$WedMiles','$ThuTownFrom','$ThuPostcodeFrom','$ThuTownTo','$ThuPostcodeTo','$ThuMiles','$FriTownFrom','$FriPostcodeFrom','$FriTownTo','$FriPostcodeTo','$FriMiles','$SatTownFrom','$SatPostcodeFrom','$SatTownTo','$SatPostcodeTo','$SatMiles','$SunTownFrom','$SunPostcodeFrom','$SunTownTo','$SunPostcodeTo','$SunMiles','$SumMiles','$MonCheck','$TueCheck','$WedCheck','$ThuCheck','$FriCheck','$SatCheck','$SunCheck','$MonHours','$TueHours','$WedHours','$ThuHours','$FriHours','$SatHours','$SunHours','$SumHours','$MonTravel','$TueTravel','$WedTravel','$ThuTravel','$FriTravel','$SatTravel','$SunTravel','$MonMealCheck','$TueMealCheck','$WedMealCheck','$ThuMealCheck','$FriMealCheck','$SatMealCheck','$SunMealCheck','$MonEveningMealCheck','$TueEveningMealCheck','$WedEveningMealCheck','$ThuEveningMealCheck','$FriEveningMealCheck','$SatEveningMealCheck','$SunEveningMealCheck','$MonOvernightCheck','$TueOvernightCheck','$WedOvernightCheck','$ThuOvernightCheck','$FriOvernightCheck','$SatOvernightCheck','$SunOvernightCheck')";
    //execute insert
            $result = mysql_query($insert);
    //validation
            if ($result)
            {
                echo("<br>Thank you for your mileage form submission. Your form will be processed as soon as possible.");
            }else
            {
                echo("<br>Your form has not been submitted. Please check the data and try again.");
            }
    ?>
    May seem a little bit messy due to the number of fields in the form (i'm sure there's a way to make it easier).
    The fields i'm having trouble with are:
    SumMiles
    SumHours

  3. #18
    Join Date
    Oct 2012
    Posts
    24
    The html for the form is below, which includes the calculation code for how to come up with those fields.
    The sum values appear on the site when you type them live, but aren't posted for some reason.
    I've had to split the code in three due to the length.

    Code:
    <?php
      //Buffer larger content areas like the main page content
      ob_start();
    ?>
      <script type="text/javascript">
        $(document).ready(function() {
          $('.sigPad').signaturePad();
        });
      </script>
    <script type="text/javascript">
        $(document).ready(function(){
     
            //iterate through each textboxes and add keyup
            //handler to trigger sum event
            $(".formmiles").each(function() {
     
                $(this).keyup(function(){
                    calculateSum();
                });
            });
     
        });
     
        function calculateSum() {
     
            var sum = 0;
            //iterate through each textboxes and add the values
            $(".formmiles").each(function() {
     
                //add only if the value is number
                if(!isNaN(this.value) && this.value.length!=0) {
                    sum += parseFloat(this.value);
                }
     
            });
            //.toFixed() method will roundoff the final sum to 2 decimal places
            $("#summiles").html(sum.toFixed(2));
        }
    </script>
    <script type="text/javascript">
        $(document).ready(function(){
     
            //iterate through each textboxes and add keyup
            //handler to trigger sum event
            $(".formhours").each(function() {
     
                $(this).keyup(function(){
                    calculateSum1();
                });
            });
     
        });
     
        function calculateSum1() {
     
            var sum1 = 0;
            //iterate through each textboxes and add the values
            $(".formhours").each(function() {
     
                //add only if the value is number
                if(!isNaN(this.value) && this.value.length!=0) {
                    sum1 += parseFloat(this.value);
                }
     
            });
            //.toFixed() method will roundoff the final sum to 2 decimal places
            $("#sumhours").html(sum1.toFixed(2));
        }
    </script>
    <script type="text/javascript">
        $(document).ready(function(){
     
            //iterate through each textboxes and add keyup
            //handler to trigger sum event
            $(".formtravel").each(function() {
     
                $(this).keyup(function(){
                    calculateSum2();
                });
            });
     
        });
     
        function calculateSum2() {
     
            var sum2 = 0;
            //iterate through each textboxes and add the values
            $(".formtravel").each(function() {
     
                //add only if the value is number
                if(!isNaN(this.value) && this.value.length!=0) {
                    sum2 += parseFloat(this.value);
                }
     
            });
            //.toFixed() method will roundoff the final sum to 2 decimal places
            $("#sumtravel").html(sum2.toFixed(2));
        }
    </script>
    <script type="text/javascript">
    <!--
    function updatesum() {
    document.sumform.sumtotal.value = (document.sumform.sumhours.value -0) + (document.sumform.sumtravel.value -0);
    }
    //-->
    </script>
    <table width="100%">
    
        <tr>
            <td valign="top">
                <div class="SubMenuBig">
                    <img src="Images/Pages/2.png" style="top: 0px; position: relative; margin-left:-5px ; " class="SubMenuImage" />
                    <h2 id="ctl00_ContentPlaceHolder1_h1Hdr" class="H1Banner">Daily Mileage & Subsistence Expenses Claim Form</h2>
                </div>
                <table>
                <tr>
                    <td align="left" colspan="4">
                        <p>
                        Please fully complete this form and submit to TJW Contract Solutions
                        <br>
                        Fields marked with an asterisk (*) are required
                        </p>
                    </td>                            
     			</tr>
                </table>
                <div class="SubMenuItemBig">

  4. #19
    Join Date
    Oct 2012
    Posts
    24
    Part 2 of 3

    Code:
       <form class="sigPad" method="post" action="Scripts/tjwformsubmit.php">
                        <table width="500" cellpadding="3">
                          <td colspan="6">
                          
                    			<div class="FormBanner">
                                <h3 id="ctl00_ContentPlaceHolder1_h1Hdr" class="FormBanner">Personal Details</h3>
                                </div>
                          </td>
    						<tr>
                           	  <td> Name: *</td>
                           	  <td><input name="EmployeeName" type="text"id="employeename" class="formfield"/></td>
                              <td> Employee Ref: *</td>
                              <td><input name="EmployeeRef" type="text" id="employeeref" class="formfield"/></td>
                              <td> Week Ending Date:
                              <select name="WeeksPerYear">
                              <option value="W1">30/09/2012</option>
                              <option value="W2">07/10/2012</option>
                              <option value="W3">14/10/2012</option>
                              <option value="W4">21/10/2012</option>
                              </select>
                            </td>                           
    					  </tr>
                          <tr>
                           <td>
                           </td>
                           	  <td colspan="4">
                              <div class="FormBanner">
                    			<h3 id="ctl00_ContentPlaceHolder1_h1Hdr" class="FormBanner">Site Location and Journey Detail
                                <br/>
                                Must be entered, stating towns and postcodes (The wording "Various Sites" will not be accepted)
                                </h3>
                              </div>
                           	  </td>
                              
                          </tr>
                          <tr>
                              <tr>
                              <td>
                           	  <td class="location" colspan="2"> From </td>
                              <td class="location" colspan="2"> To </td>
                          </tr>
                          <tr>
                              <tr>
                              <td>
                          	  <td class="location"> Town </td>
                              <td class="location"> Postcode </td>
                              <td class="location"> Town </td>
                              <td class="location"> Postcode </td> 
                              <td class="location"> Total Miles Driven Per Day
                              </td>                           
    					  </tr>
                          <tr>
                           	  <td class="example"> Example </td>
                           	  <td><input name="TownFrom" value="Mitcham" type="text"id="townfrom" class="formfield" readonly="readonly"/></td>
                              <td><input name="PostcodeFrom" value="CR4 3NW" type="text" id="postcodefrom" class="formfield" readonly="readonly"/></td> 
                              <td><input name="TownTo" value="Egham" type="text"id="townto" class="formfield" readonly="readonly"/></td>
                              <td><input name="PostcodeTo" value="TW20 0LR" type="text" id="postcodeto" class="formfield" readonly="readonly"/></td>
                              <td><input name="ExampleMiles" value="55" type="text" id="examplemiles" class="formexample" readonly="readonly"/></td>                           
    					  </tr>
                          <tr>
                           	  <td> Monday </td>
                           	  <td><input name="MonTownFrom" type="text"id="montownfrom" class="formfield"/></td>
                              <td><input name="MonPostcodeFrom" type="text" id="monpostcodefrom" class="formfield"/></td> 
                              <td><input name="MonTownTo" type="text"id="montownto" class="formfield"/></td>
                              <td><input name="MonPostcodeTo" type="text" id="monpostcodeto" class="formfield"/></td>
                              <td><input name="MonMiles" type="text" id="monmiles" onchange="calc('monmiles','tuemiles','wedmiles','thumiles','frimiles','satmiles','sunmiles','milesresult')" class="formmiles"/></td>                           
    					  </tr>
                          <tr>
                           	  <td> Tuesday </td>
                           	  <td><input name="TueTownFrom" type="text"id="tuetownfrom" class="formfield"/></td>
                              <td><input name="TuePostcodeFrom" type="text" id="tuepostcodefrom" class="formfield"/></td> 
                              <td><input name="TueTownTo" type="text"id="tuetownto" class="formfield"/></td>
                              <td><input name="TuePostcodeTo" type="text" id="tuepostcodeto" class="formfield"/></td>
                              <td><input name="TueMiles" type="text" id="tuemiles" onchange="calc('monmiles','tuemiles','wedmiles','thumiles','frimiles','satmiles','sunmiles','milesresult')" class="formmiles"/></td>                           
    					  </tr>
                          <tr>
                           	  <td> Wednesday </td>
                           	  <td><input name="WedTownFrom" type="text"id="wedtownfrom" class="formfield"/></td>
                              <td><input name="WedPostcodeFrom" type="text" id="wedpostcodefrom" class="formfield"/></td> 
                              <td><input name="WedTownTo" type="text"id="wedtownto" class="formfield"/></td>
                              <td><input name="WedPostcodeTo" type="text" id="wedpostcodeto" class="formfield"/></td>
                              <td><input name="WedMiles" type="text" id="wedmiles" onchange="calc('monmiles','tuemiles','wedmiles','thumiles','frimiles','satmiles','sunmiles','milesresult')" class="formmiles"/></td>                           
    					  </tr>
                          <tr>
                           	  <td> Thursday </td>
                           	  <td><input name="ThuTownFrom" type="text"id="thutownfrom" class="formfield"/></td>
                              <td><input name="ThuPostcodeFrom" type="text" id="thupostcodefrom" class="formfield"/></td> 
                              <td><input name="ThuTownTo" type="text"id="thutownto" class="formfield"/></td>
                              <td><input name="ThuPostcodeTo" type="text" id="thupostcodeto" class="formfield"/></td>
                              <td><input name="ThuMiles" type="text" id="thumiles" onchange="calc('monmiles','tuemiles','wedmiles','thumiles','frimiles','satmiles','sunmiles','milesresult')" class="formmiles"/></td>                           
    					  </tr>
                          <tr>
                           	  <td> Friday </td>
                           	  <td><input name="FriTownFrom" type="text"id="fritownfrom" class="formfield"/></td>
                              <td><input name="FriPostcodeFrom" type="text" id="fripostcodefrom" class="formfield"/></td> 
                              <td><input name="FriTownTo" type="text"id="fritownto" class="formfield"/></td>
                              <td><input name="FriPostcodeTo" type="text" id="fripostcodeto" class="formfield"/></td>
                              <td><input name="FriMiles" type="text" id="frimiles" onchange="calc('monmiles','tuemiles','wedmiles','thumiles','frimiles','satmiles','sunmiles','milesresult')" class="formmiles"/></td>                           
    					  </tr>
                          <tr>
                           	  <td> Saturday </td>
                           	  <td><input name="SatTownFrom" type="text"id="sattownfrom" class="formfield"/></td>
                              <td><input name="SatPostcodeFrom" type="text" id="satpostcodefrom" class="formfield"/></td> 
                              <td><input name="SatTownTo" type="text"id="sattownto" class="formfield"/></td>
                              <td><input name="SatPostcodeTo" type="text" id="satpostcodeto" class="formfield"/></td>
                              <td><input name="SatMiles" type="text" id="satmiles" onchange="calc('monmiles','tuemiles','wedmiles','thumiles','frimiles','satmiles','sunmiles','milesresult')" class="formmiles"/></td>                           
    					  </tr>
                          <tr>
                           	  <td> Sunday </td>
                           	  <td><input name="SunTownFrom" type="text"id="suntownfrom" class="formfield"/></td>
                              <td><input name="SunPostcodeFrom" type="text" id="sunpostcodefrom" class="formfield"/></td> 
                              <td><input name="SunTownTo" type="text"id="suntownto" class="formfield"/></td>
                              <td><input name="SunPostcodeTo" type="text" id="sunpostcodeto" class="formfield"/></td>
                              <td><input name="SunMiles" type="text" id="sunmiles" onchange="calc('monmiles','tuemiles','wedmiles','thumiles','frimiles','satmiles','sunmiles','milesresult')" class="formmiles"/></td>                           
    					  </tr>
                          <tr id="summation">
                          <td>
                          </td>
                          <td>Weekly Total
                          </td>
                          <td> <span name="SumMiles" id="summiles">0</span>
                          </td>
                          </tr>
                          <tr>
                          <br />
                          Full postcodes and towns must be entered.
                          </td>
                          </tr>
                          </table>

  5. #20
    Join Date
    Oct 2012
    Posts
    24
    Part 3 of 3

    Code:
                          <!--<form name="sumform">-->
                          <table>
                          <tr>
                           	  <td></td>
                           	  <td class="location">Monday</td>
                              <td class="location">Tuesday</td> 
                              <td class="location">Wednesday</td>
                              <td class="location">Thursday</td>
                              <td class="location">Friday</td>
                              <td class="location">Saturday</td>
                              <td class="location">Sunday</td>
                              <td class="location">Total</td>                           
    					  </tr>
                           <tr>
                          <td> Cost Incurred </td>
                           	  <td><input name="MonCheck" type="checkbox" id="moncheck" class="formcheck"/></td>
                              <td><input name="TueCheck" type="checkbox" id="tuecheck" class="formcheck"/></td> 
                              <td><input name="WedCheck" type="checkbox" id="wedcheck" class="formcheck"/></td>
                              <td><input name="ThuCheck" type="checkbox" id="thucheck" class="formcheck"/></td>
                              <td><input name="FriCheck" type="checkbox" id="fricheck" class="formcheck"/></td>
                              <td><input name="SatCheck" type="checkbox" id="satcheck" class="formcheck"/></td>
                              <td><input name="SunCheck" type="checkbox" id="suncheck" class="formcheck"/></td>
                              <td></td>
                          </tr>
                          <tr>
                           	  <td> Hours Worked </td>
                           	  <td><input name="MonHours" type="text" id="monhours" class="formhours"/></td>
                              <td><input name="TueHours" type="text" id="tuehours" class="formhours"/></td> 
                              <td><input name="WedHours" type="text" id="wedhours" class="formhours"/></td>
                              <td><input name="ThuHours" type="text" id="thuhours" class="formhours"/></td>
                              <td><input name="FriHours" type="text" id="frihours" class="formhours"/></td>
                              <td><input name="SatHours" type="text" id="sathours" class="formhours"/></td>
                              <td><input name="SunHours" type="text" id="sunhours" class="formhours"/></td>
                              <td><span  name="SumHours" id="sumhours" onchange="updatesum()">0.00</td>                           
    					  </tr>
                          <tr>
                           	  <td> Travel Time </td>
                           	  <td><input name="MonTravel" type="text" id="montravel" class="formtravel"/></td>
                              <td><input name="TueTravel" type="text" id="tuetravel" class="formtravel"/></td> 
                              <td><input name="WedTravel" type="text" id="wedtravel" class="formtravel"/></td>
                              <td><input name="ThuTravel" type="text" id="thutravel" class="formtravel"/></td>
                              <td><input name="FriTravel" type="text" id="fritravel" class="formtravel"/></td>
                              <td><input name="SatTravel" type="text" id="sattravel" class="formtravel"/></td>
                              <td><input name="SunTravel" type="text" id="suntravel" class="formtravel"/></td>
                              <td></td>
                          </table>
                    <!--</form>-->
                    <table>
                    <tr>
                          <td colspan="9" class="FormBanner">
                          Meal Allowances
                          <br />
                          You can claim 5 for breakfast (where you start before 6am) or evening meal (where you finish after 8pm)
                          <br />
                          (In exceptional circumstances only, I.E. not as a part of your normal work pattern)
                          </td>
                          </tr>
                    <tr>
                          
                          <td> Breakfast </td>
                           	  <td><input name="MonMealCheck" type="checkbox" id="monmealcheck" class="formcheck"/></td>
                              <td><input name="TueMealCheck" type="checkbox" id="tuemealcheck" class="formcheck"/></td> 
                              <td><input name="WedMealCheck" type="checkbox" id="wedmealcheck" class="formcheck"/></td>
                              <td><input name="ThuMealCheck" type="checkbox" id="thumealcheck" class="formcheck"/></td>
                              <td><input name="FriMealCheck" type="checkbox" id="frimealcheck" class="formcheck"/></td>
                              <td><input name="SatMealCheck" type="checkbox" id="satmealcheck" class="formcheck"/></td>
                              <td><input name="SunMealCheck" type="checkbox" id="sunmealcheck" class="formcheck"/></td>
                              <td></td>
                    </tr>         
                    <tr>
                          
                          <td> Evening Meal </td>
                           	  <td><input name="MonEveningMealCheck" type="checkbox" id="moneveningmealcheck" class="formcheck"/></td>
                              <td><input name="TueEveningMealCheck" type="checkbox" id="tueeveningmealcheck" class="formcheck"/></td> 
                              <td><input name="WedEveningMealCheck" type="checkbox" id="wedeveningmealcheck" class="formcheck"/></td>
                              <td><input name="ThuEveningMealCheck" type="checkbox" id="thueveningmealcheck" class="formcheck"/></td>
                              <td><input name="FriEveningMealCheck" type="checkbox" id="frieveningmealcheck" class="formcheck"/></td>
                              <td><input name="SatEveningMealCheck" type="checkbox" id="sateveningmealcheck" class="formcheck"/></td>
                              <td><input name="SunEveningMealCheck" type="checkbox" id="suneveningmealcheck" class="formcheck"/></td>
                              <td></td>
                    </tr>
                    <tr> 
                          <td> Overnight Allowance </td>
                           	  <td><input name="MonOvernightCheck" type="checkbox" id="monovernightcheck" class="formcheck"/></td>
                              <td><input name="TueOvernightCheck" type="checkbox" id="tueovernightcheck" class="formcheck"/></td> 
                              <td><input name="WedOvernightCheck" type="checkbox" id="wedovernightcheck" class="formcheck"/></td>
                              <td><input name="ThuOvernightCheck" type="checkbox" id="thuovernightcheck" class="formcheck"/></td>
                              <td><input name="FriOvernightCheck" type="checkbox" id="friovernightcheck" class="formcheck"/></td>
                              <td><input name="SatOvernightCheck" type="checkbox" id="satovernightcheck" class="formcheck"/></td>
                              <td><input name="SunOvernightCheck" type="checkbox" id="sunovernightcheck" class="formcheck"/></td>
                              <td></td>
                   </tr>            
       <!--</form>-->         
    </table>
    <p>
    </p>
    <!--<form class="sigPad">-->
    <label for="name">Print your name</label>
        <input type="text" name="name" id="name" class="name">
        <p class="typeItDesc">Review your signature</p>
        <p class="drawItDesc">Draw your signature</p>
        <ul class="sigNav">
          <li class="typeIt"><a href="#type-it" class="current">Type It</a></li>
          <li class="drawIt"><a href="#draw-it" >Draw It</a></li>
          <li class="clearButton"><a href="#clear">Clear</a></li>
        </ul>
        <div class="igWrapper">
          <div class="typed"></div>
          <canvas class="pad" width="198" height="55"></canvas>
          <input type="hidden" name="output" class="output">
        </div>
        <button type="submit">I accept the terms of this agreement.</button>
    </form>
    
    
    <?php
      //Assign all Page Specific variables
      $pagemaincontent = ob_get_contents();
      ob_end_clean();
      $pagetitle = "test form";
      //Apply the template
      include("master.php");
    ?>
    I have no doubt that you'll look at this and think it's amateur, but I am trying!
    Thanks for your help.

  6. #21
    Join Date
    Oct 2012
    Posts
    24
    I posted two more replies to the thread but they are waiting for moderator approval before being posted for some reason.
    Apologies that they may appear out of order!

  7. #22
    Join Date
    Mar 2009
    Posts
    452
    what errors you get now ?

    is error from PHP or from MySQL ?

  8. #23
    Join Date
    Oct 2012
    Posts
    24
    The error is the same as before:

    [Thu Oct 11 22:59:09 2012] [error] [client x.x.x.x] PHP Notice: Undefined variable: SumMiles in /home/test/public_html/Beta/Scripts/formsubmit.php on line 46, referer: http://www.test.com/Beta/mileage3.php
    [Thu Oct 11 22:59:09 2012] [error] [client x.x.x.x] PHP Notice: Undefined variable: SumHours in /home/test/public_html/Beta/Scripts/formsubmit.php on line 46, referer: http://www.test.com/Beta/mileage3.php

  9. #24
    Join Date
    Oct 2012
    Posts
    11
    I using tried using this code, but it for some reason is only adding the digits together, resulting in 1+2=12

  10. #25
    Join Date
    Mar 2009
    Posts
    452
    after adding error_reporting(E_ALL ^ E_NOTICE); as a first statement in your php file what errors do you get

  11. #26
    Join Date
    Oct 2012
    Posts
    24
    After I add error_reporting(E_ALL ^ E_NOTICE); to the php file, the error messages stop being logged to the log file and the front end doesn't display any errors either (apart from the if else error message I programmed into the php file, I.E. the data still doesn't insert).

  12. #27
    Join Date
    Mar 2009
    Posts
    452
    hmmmm, OK keep it in the beginning of your file as is; it seems there is no problem with your PHP code, then change $result = mysql_query($insert); to $result = mysql_query($insert) or die(mysql_errors()); now see what MySQL errors you get.

  13. #28
    Join Date
    Oct 2012
    Posts
    1
    Hi

    I'm working on a script for an invoicing thing and I've run into a javascript thing that is driving me nuts.

    Are there any javascript gurus hanging around? If anyone is feeling generous, would you have a look?

    http://mediawizard.ca/work/single.html

    I have the single row working great, but I can't seem to get multiple rows working.

    Thank you in advance for any tips!

    Mark

  14. #29
    Join Date
    Sep 2014
    Posts
    2

    with a while loop!

    Hey, this basic code for dynamically calculating fields is great. I'm trying to add about 200 fields though, so I thought I should use a while loop. What I've tried doesn't seem to work. I'm pretty new to javascript so I'm not sure what's wrong. Can anyone see why this isn't working?

    Code:
    <script type="text/javascript">
    	function updatesum() {
    		while (i <= 3) {
    		    document.form.sum.value += (document.form.sum[i].value -0);
    		    i++;
    			}
    	}
    </script>
    
    <body>
    
    <form name="form" >
    Enter a number:
    <input name="sum1" onChange="updatesum()" />
    and:
    <input name="sum2" onChange="updatesum()" />
    and:
    <input name="sum3" onChange="updatesum()" />
    Their sum is:
    <input name="sum" readonly style="border:0px;">
    </form>
    
    </body>

  15. #30
    Join Date
    Dec 2005
    Location
    FL
    Posts
    7,436
    sum[1] is not the same as sum1

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles