5 Replies Latest reply: Mar 19, 2013 6:50 AM by Ness_quick RSS

    Calculation rule

    Ness_quick Community Member

      So what i would like to achieve is in my estimator, in the "Choice of coffin" section, in order for the Additional services' (drop down menu) to calculate, the radio button (above) for 'Simple Basic coffin' has to be selected. Basically those additional services are only available if the basic simple coffin is chosen.

       

      I just cant get my head around how to restrict that drop down calculation from happening if simple basic not chosen.

       

      http://www.milesmemorials.com/estimator.html

       

      Any help appreciated!

        • 1. Re: Calculation rule
          kennethkawamoto2 Community Member

          You can disable <select> with disabled attribute.

           

          --

          Kenneth Kawamoto

          http://www.materiaprima.co.uk/

          • 2. Re: Calculation rule
            MurraySummers ACP/MVPs

            Try this - add the following bold code to your javascript in the indicated location -

             

            cemetery_fee = Number(document.catwebformform22057.CAT_Custom_76931.value)

             

            zz=document.getElementById('CAT_Custom_76926_0').checked==true;if(zz) { document.getElementById('basicServices').style.display='block'; } else { document.getElementById('basicServices').style.display='none'; };

             

            Then change this -

             

            <select name="CAT_Custom_00010"

             

            to this -

             

            <span id="basicServices"><select name="CAT_Custom_00010"

             

            and this -

             

            <option value="545" >Limousine,Chapel visiting, Choice of date & time (&pound;545)</option>

                                    </select></td>

             

            to this -

             

            <option value="545" >Limousine,Chapel visiting, Choice of date & time (&pound;545)</option>

                                    </select></span></td>

             

             

            Finally, add this to your CSS -

             

            #basicServices {

            display:none;

            }

             

            See if that does what you want.

            • 3. Re: Calculation rule
              Ness_quick Community Member

              Excellent that works really well. Thank you!

               

              Im trying created a php file (estimate-to-email.php) to go with this page so that all the information that is selected including the values of those selections is sent in an email. BUT! Im not sure how to collect the informations in the sections that only calculate if chosen for example - The 'Additional services' just created, 'Burial' (plus all the info within this section) and 'Cremation' (again plus all the info within this section)?

               

              This is what ive created so far. (ive left out the sections that im not sure about)

               

              <?php

              if(!isset($_POST['submit']))

              {

                        //This page should not be accessed directly. Need to submit the form.

                        echo "error; you need to submit the form!";

              }

              $CAT_Custom_76922 = $_POST['CAT_Custom_76922'];

              $CAT_Custom_00000 = $_POST['CAT_Custom_00000'];

              $CAT_Custom_76926 = $_POST['CAT_Custom_76926'];

              $CAT_Custom_76924 = $_POST['CAT_Custom_76924'];

              $CAT_Custom_76927 = $_POST['CAT_Custom_76927'];

              $FirstName = $_POST['FirstName'];

              $LastName = $_POST['LastName'];

              $EmailAddress= $_POST['EmailAddress'];

              $HomeAddress = $_POST['HomeAddress'];

              $HomeCity = $_POST['HomeCity'];

              $HomeState = $_POST['HomeState'];

              $HomeZip = $_POST['HomeZip'];

              $HomeCountry = $_POST['HomeCountry'];

              $HomePhone = $_POST['HomePhone'];

              $CellPhone = $_POST['CellPhone'];

               

               

               

               

              //Validate first

              if(empty($CAT_Custom_76922)||empty($CAT_Custom_00000)||empty($CAT_Custom_76926)||empty($CA T_Custom_76924)||empty($CAT_Custom_76927)||empty($FirstName)||empty($LastName)||empty($Ema ilAddress)||empty($HomeAddress)|empty($HomeCity)|empty($HomeState)|empty($HomeZip)|empty($ HomeCountry)|empty($HomePhone)||empty($CellPhone))

              {

                  echo "Please make sure all fields are filled in!";

                  exit;

              }

               

               

              if(IsInjected($EmailAddress))

              {

                  echo "Bad email value!";

                  exit;

              }

               

               

              $email_from = '$EmailAddress';//<== update the email address

              $email_subject = "Estimate from M&D website";

              $email_body .= "Name: $FirstName.\n";

              $email_body .= "Surname: $LastName.\n";

              $email_body .= "Address: $HomeAddress.\n";

              $email_body .= "City: $HomeCity.\n";

              $email_body .= "County: $HomeState.\n";

              $email_body .= "Postcode: $HomeZip.\n";

              $email_body .= "Country: $HomeCountry.\n";

              $email_body .= "Phone: $HomePhone.\n";

              $email_body .= "Mob: $CellPhone.\n";

              $email_body .= "Removal milage: $CAT_Custom_76922.\n";

              $email_body .= "Viewing: $CAT_Custom_00000.\n";

              $email_body .= "Coffin: $CAT_Custom_76926.\n";

              $email_body .= "Route: $CAT_Custom_76924.\n";

              $email_body .= "Limousines: $CAT_Custom_76927.\n";

               

               

               

               

                 

              $to = "Ness_Rob@yahoo.com";//<== update the email address

              $headers = 'From: '.$EmailAddress."\r\n";

              $headers .='Reply-To:'.$EmailAddress."\r\n";

              //Send the email!

              mail($to,$email_subject,$email_body,$headers);

              //done.  redirect to payment page.

              header('Location: thankyou_estimate.html');

               

               

              // Function to validate against any email injection attempts

              function IsInjected($str)

              {

                $injections = array('(\n+)',

                            '(\r+)',

                            '(\t+)',

                            '(%0A+)',

                            '(%0D+)',

                            '(%08+)',

                            '(%09+)'

                            );

                $inject = join('|', $injections);

                $inject = "/$inject/i";

                if(preg_match($inject,$str))

                  {

                  return true;

                }

                else

                  {

                  return false;

                }

              }

                

              ?>

              • 4. Re: Calculation rule
                MurraySummers ACP/MVPs

                Why don't you post this in a separate thread? That way you can mark my answer as correct in this one!

                • 5. Re: Calculation rule
                  Ness_quick Community Member

                  Okey Dokey will do!!