Error checking form selection dropdown option

3 posts by 2 authors in: Forums > CMS Builder
Last Post: October 31, 2016   (RSS)

By dmn - October 26, 2016

I have a form with dropdowns for Month, Day, Year and also multiple choice quiz questions, which is writing to CMSB database. Everything works fine and it is writing to the db. Problem is if any of the dropdowns are unselected there is no Error Alert. If you leave a textfield empty there is an Error Alert.  I have the dropdowns setup to show an error if a value is not selected. I have several of these forms to do and would like to find the solution as it is imperative that test takers don't leave questions unanswered. What am I missing? Here is the page in question.

<?php header('Content-type: text/html; charset=utf-8'); ?>
<?php
 
 
  // load viewer library
  $libraryPath = 'cmsb/lib/viewer_functions.php';
  $dirsToCheck = array('/var/www/vhosts/xxxx.xxxx/httpdocs/','','../','../../','../../../');
  foreach ($dirsToCheck as $dir) { if (@include_once("$dir$libraryPath")) { break; }}
  if (!function_exists('getRecords')) { die("Couldn't load viewer library, check filepath in sourcecode."); }
 list($mainnavcategoryRecords, $mainnav_selectedCategory) = getCategories(array(
    'tableName'   => 'mainnavcategory',
     'selectedCategoryNum' => '',         // defaults to getNumberFromEndOfUrl()
   'categoryFormat'       => 'showall',
    'ulAttributesCallback' => 'customMenuUlAttr', // ADVANCED: custom function to return ul attributes, eg: myUlAttr($category);

  ));

 function customMenuUlAttr($category) {
  return ($category['_hasParent'] && $category['depth'] == '1')? "class=\"gal-sub-menu\" role=\"navigation\"" : "" ;
}
// load records from 'sitepages'
  list($sitepagesRecords, $sitepagesMetaData) = getRecords(array(
    'tableName'   => 'sitepages',
    'loadUploads' => true,
    'allowSearch' => false,
  ));
 
 // load records from 'footer'
  list($footerRecords, $footerMetaData) = getRecords(array(
    'tableName'   => 'footer',
    'loadUploads' => true,
    'allowSearch' => false,
  ));
  // load records from 'sitepages'
  list($sitepagesRecords, $sitepagesMetaData) = getRecords(array(
    'tableName'   => 'sitepages',
    'loadUploads' => true,
    'allowSearch' => false,
  ));
 
 // load records from 'quiz_module_3'
  list($quiz_module_3Records, $quiz_module_3MetaData) = getRecords(array(
    'tableName'   => 'quiz_module_3',
  ));
    // submit form
if (@$_REQUEST['submit']) {
// error checking
$errorsAndAlerts = "";
if (!@$_REQUEST['first_name']) { $errorsAndAlerts .= "Please specify First Name in Personal Information Section!<br/>\n"; }
if (!@$_REQUEST['last_name']) { $errorsAndAlerts .= "Please specify Last Name in Personal Information Section!<br/>\n"; }
if (!@$_REQUEST['email']) { $errorsAndAlerts .= "Please specify Email Address in Personal Information Section!<br/>\n"; }
if (!@$_REQUEST['telephone']) { $errorsAndAlerts .= "Please specify Telephone in Personal Information Section!<br/>\n"; }
if (!@$_REQUEST['month']) { $errorsAndAlerts .= "Please specify month in Personal Information Section!<br/>\n"; }
if (!@$_REQUEST['day']) { $errorsAndAlerts .= "Please specify day in Personal Information Section!<br/>\n"; }
if (!@$_REQUEST['year']) { $errorsAndAlerts .= "Please specify year in Personal Information Section!<br/>\n"; }
if (!@$_REQUEST['question_1']) { $errorsAndAlerts .= "Please answer Question 1!<br/>\n"; }
if (!@$_REQUEST['question_2']) { $errorsAndAlerts .= "Please answer Question 2!<br/>\n"; }
if (!@$_REQUEST['question_3']) { $errorsAndAlerts .= "Please answer Question 3!<br/>\n"; }
if (!@$_REQUEST['question_4']) { $errorsAndAlerts .= "Please answer Question 4!<br/>\n"; }
if (!@$_REQUEST['question_5']) { $errorsAndAlerts .= "Please answer Question 5!<br/>\n"; }
if (!@$_REQUEST['question_6']) { $errorsAndAlerts .= "Please answer Question 6!<br/>\n"; }
if (!@$_REQUEST['question_7']) { $errorsAndAlerts .= "Please answer Question 7!<br/>\n"; }
// turn off strict mysql error checking for: STRICT_ALL_TABLES
mysqlStrictMode(false); // disable Mysql strict errors for when a field isn't defined below (can be caused when fields are added later)
// add record
if (!@$errorsAndAlerts) {
mysql_query("INSERT INTO `{$TABLE_PREFIX}quiz_module_3` SET
first_name = '".mysql_real_escape_string( $_REQUEST['first_name'] )."',
last_name = '".mysql_real_escape_string( $_REQUEST['last_name'] )."',
email = '".mysql_real_escape_string( $_REQUEST['email'] )."',
telephone = '".mysql_real_escape_string( $_REQUEST['telephone'] )."',
month = '".mysql_real_escape_string( $_REQUEST['month'] )."',
day = '".mysql_real_escape_string( $_REQUEST['day'] )."',
year = '".mysql_real_escape_string( $_REQUEST['year'] )."',
question_1 = '".mysql_real_escape_string( $_REQUEST['question_1'] )."',
question_2 = '".mysql_real_escape_string( $_REQUEST['question_2'] )."',
question_3 = '".mysql_real_escape_string( $_REQUEST['question_3'] )."',
question_4 = '".mysql_real_escape_string( $_REQUEST['question_4'] )."',
question_5 = '".mysql_real_escape_string( $_REQUEST['question_5'] )."',
question_6 = '".mysql_real_escape_string( $_REQUEST['question_6'] )."',
question_7 = '".mysql_real_escape_string( $_REQUEST['question_7'] )."',
createdDate = NOW(),
updatedDate = NOW(),
createdByUserNum = '0',
updatedByUserNum = '0'")
or die("MySQL Error Creating Record:<br/>\n". htmlspecialchars(mysql_error()) . "\n");
$recordNum = mysql_insert_id();
$to="xxx@xxxxx.ca";
$subject="Module 3";
//if(@$_REQUEST['newsletter_sign_up']){$_REQUEST['newsletter_sign_up']=1;}else{$_REQUEST['newsletter_sign_up']=0;}
$message=<<<__TEXT__
A Dangerous Goods Quiz was added:

First Name: {$_REQUEST['first_name']}
Last Name: {$_REQUEST['last_name']}
Telephone: {$_REQUEST['telephone']}
Email Address: {$_REQUEST['email']}

__TEXT__;
mail($to,$subject,$message);
// display thanks message and clear form
$errorsAndAlerts = "We have received your Module 3.";
$_REQUEST = array();
 header("Location: http://www.xxxxx.ca/");
 



}
}
?>
<?php if (!$CURRENT_USER) { websiteLogin_redirectToLogin(); }
  // prepopulate form with current user values
  foreach ($CURRENT_USER as $name => $value) {
    if (array_key_exists($name, $_REQUEST)) { continue; }
    $_REQUEST[$name] = $value;
  }?>
    <title>Quiz Module 3: Winching </title>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    
    <meta name="viewport" content="width=device-width, initial-scale=1">
    
  <meta name="keywords" content="" />



  <!-- Place favicon.ico and apple-touch-icon.png in the root directory -->
  <link rel="shortcut icon" href="favicon.ico">

  <!-- Google Webfont -->
    <link href='http://fonts.googleapis.com/css?family=Lato:300,400|Crimson+Text' rel='stylesheet' type='text/css'>
    <!-- Themify Icons -->
    <link rel="stylesheet" href="css/themify-icons.css">
    <!-- Bootstrap -->
    <link rel="stylesheet" href="css/bootstrap.css">
    <!-- Owl Carousel -->
    <link rel="stylesheet" href="css/owl.carousel.min.css">
    <link rel="stylesheet" href="css/owl.theme.default.min.css">
    <!-- Magnific Popup -->
    <link rel="stylesheet" href="css/magnific-popup.css">
    <!-- Superfish -->
    <link rel="stylesheet" href="css/superfish.css">
    <!-- Easy Responsive Tabs -->
    <link rel="stylesheet" href="css/easy-responsive-tabs.css">

     <link rel="stylesheet" href="css/main.css">

    <!-- Theme Style -->
    <link rel="stylesheet" href="css/style.css">

    </head>
    <body class="inner-page">

            <!-- START #gal-header -->
            <header id="gal-header-section" role="header" class="" style="background:url(images/header_bg.png)left top repeat-x;">
                <div class="container">
                    
                    <!-- START #gal-logo -->
                    <h1 id="gal-logo" class="pull-left"><a href="index.html"><img src="images/logo.png" alt="" width="116" height="120" border="0"></a></h1>
                    
                    <!-- START #gal-menu-wrap -->
                    <nav id="gal-menu-wrap" role="navigation">
                        <ul class="sf-menu" id="gal-primary-menu">
                           <?php foreach ($mainnavcategoryRecords as $categoryRecord): ?>
<?php echo $categoryRecord['_listItemStart'] ?>

<?php if ($categoryRecord['_hasChild']): ?>
<a href="http://www.xxx.ca/new/sitepages.php?category=<?php echo $categoryRecord['num'] ?>" ><?php echo $categoryRecord['name'] ?></a>
<?php else: ?>
<a href="http://www.xxxx.ca/new/sitepages.php?category=<?php echo $categoryRecord['num'] ?>"><?php echo $categoryRecord['name'] ?></a>
<?php endif; ?>

<?php echo $categoryRecord['_listItemEnd'] ?>
<?php endforeach; ?>
                            
                            
                        </ul>
                    </nav>

                </div>
            </header>
            
            <div id="gal-main">
                <!-- Start Page Banner -->
    <div class="page-banner" style="margin-bottom:50px;padding:2% 0 2% 14%;>
    
      <div class="container">
        <div class="row">
          <div class="col-md-6">
            <h2>Module 3</h2>
            
          </div>
         
        </div>
      </div>
    
    </div>
    <!-- End Page Banner -->
      
     
      
   
    <section>
                    
                    <div class="container">
                        <div class="row">
                            <div class="col-md-9 col-md-offset-1 col-md-push-1">
                            <p align="center">Instructions: Read the question thoroughly and select the correct answer. This is the second of 5 modules. The five modules comprise a total of 27 questions. Student must receive a minimum of 22/27 (80%) correct to pass.
<?php if (@$errorsAndAlerts): ?>
    <div align="center" style="color: #C00; font-weight: bold; font-size: 12px;font-variant:small-caps;">
      <?php echo $errorsAndAlerts; ?><br/>
    </div>
  <?php endif ?>
              </p>
                             <div class="panel-group gal-accordion" id="accordion" role="tablist" aria-multiselectable="true"> <form method="post" action="" id="sectional">
<input type="hidden" name="submit" value="1" />
<div class="panel panel-default">
    <div class="panel-heading collapsed" role="tab" id="headingTwo" data-toggle="collapse" data-parent="#accordion" data-target="#collapseTwo" aria-expanded="false" aria-controls="collapseTwo">
      <h4 class="panel-title">
          
        <a class="accordion-toggle">
          Personal Information
        </a>
      </h4>
    </div>
           <div id="collapseTwo" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingTwo">
      <div class="panel-body">
          <div class="form-group"><label for="first_name" class="control-label">First Name</label>
       <input class="form-control input-md"  name="first_name" placeholder="First Name *"  value="<?php echo htmlspecialchars(@$_REQUEST['first_name']) ?>"/> </div>      
        
        
          <div class="form-group"><label for="last_name" class="control-label">Last Name</label>
      <input class="form-control input-group-sm"  name="last_name" placeholder="Last Name *"  value="<?php echo htmlspecialchars(@$_REQUEST['last_name']) ?>"/></div>
        
  <div class="form-group">
         <label for="email" class="control-label">Email</label>
       <input class="form-control input-md"  name="email" placeholder="Email *"  value="<?php echo htmlspecialchars(@$_REQUEST['email']) ?>"/> </div>      
        
         <div class="form-group"><label for="telephone" class="control-label">Telephone</label>
        <input class="form-control input-md"  name="telephone" placeholder="Telephone *"  value="<?php echo htmlspecialchars(@$_REQUEST['telephone']) ?>"/></div>
        <div class="form-group form-inline" align="center"><select  name="month">
<option selected="selected">Select One</option>
<option value="January" <?php selectedIf(@$_REQUEST['month'], 'January') ?>>January</option>
<option value="February" <?php selectedIf(@$_REQUEST['month'], 'February') ?>>February</option>
<option value="March" <?php selectedIf(@$_REQUEST['month'], 'March') ?>>March</option>
<option value="April" <?php selectedIf(@$_REQUEST['month'], 'April') ?>>April</option>
<option value="May" <?php selectedIf(@$_REQUEST['month'], 'May') ?>>May</option>
<option value="June" <?php selectedIf(@$_REQUEST['month'], 'June') ?>>June</option>
<option value="July" <?php selectedIf(@$_REQUEST['month'], 'July') ?>>July</option>
<option value="August" <?php selectedIf(@$_REQUEST['month'], 'August') ?>>August</option>
<option value="September" <?php selectedIf(@$_REQUEST['month'], 'September') ?>>September</option>
<option value="October" <?php selectedIf(@$_REQUEST['month'], 'October') ?>>October</option>
<option value="November" <?php selectedIf(@$_REQUEST['month'], 'November') ?>>November</option>
<option value="Decemberr" <?php selectedIf(@$_REQUEST['month'], 'December') ?>>December</option>
</select>
<select  name="day">
<option selected="selected">Select One</option>
<option value="1" <?php selectedIf(@$_REQUEST['day'], '1') ?>>1</option>
<option value="2" <?php selectedIf(@$_REQUEST['day'], '2') ?>>2</option>
<option value="3" <?php selectedIf(@$_REQUEST['day'], '3') ?>>3</option>
<option value="4" <?php selectedIf(@$_REQUEST['day'], '4') ?>>4</option>
<option value="5" <?php selectedIf(@$_REQUEST['day'], '5') ?>>5</option>
<option value="6" <?php selectedIf(@$_REQUEST['day'], '6') ?>>6</option>
<option value="7" <?php selectedIf(@$_REQUEST['day'], '7') ?>>7</option>
<option value="8" <?php selectedIf(@$_REQUEST['day'], '8') ?>>8</option>
<option value="9" <?php selectedIf(@$_REQUEST['day'], '9') ?>>9</option>
<option value="10" <?php selectedIf(@$_REQUEST['day'], '10') ?>>10</option>
<option value="11" <?php selectedIf(@$_REQUEST['day'], '11') ?>>11</option>
<option value="12" <?php selectedIf(@$_REQUEST['day'], '12') ?>>12</option>
<option value="13" <?php selectedIf(@$_REQUEST['day'], '13') ?>>13</option>
<option value="14" <?php selectedIf(@$_REQUEST['day'], '14') ?>>14</option>
<option value="15" <?php selectedIf(@$_REQUEST['day'], '15') ?>>15</option>
<option value="16" <?php selectedIf(@$_REQUEST['day'], '16') ?>>16</option>
<option value="17" <?php selectedIf(@$_REQUEST['day'], '17') ?>>17</option>
<option value="18" <?php selectedIf(@$_REQUEST['day'], '18') ?>>18</option>
<option value="19" <?php selectedIf(@$_REQUEST['day'], '19') ?>>19</option>
<option value="20" <?php selectedIf(@$_REQUEST['day'], '20') ?>>20</option>
<option value="21" <?php selectedIf(@$_REQUEST['day'], '21') ?>>21</option>
<option value="22" <?php selectedIf(@$_REQUEST['day'], '22') ?>>22</option>
<option value="23" <?php selectedIf(@$_REQUEST['day'], '23') ?>>23</option>
<option value="24" <?php selectedIf(@$_REQUEST['day'], '24') ?>>24</option>
<option value="25" <?php selectedIf(@$_REQUEST['day'], '25') ?>>25</option>
<option value="26" <?php selectedIf(@$_REQUEST['day'], '26') ?>>26</option>
<option value="27" <?php selectedIf(@$_REQUEST['day'], '27') ?>>27</option>
<option value="28" <?php selectedIf(@$_REQUEST['day'], '28') ?>>28</option>
<option value="29" <?php selectedIf(@$_REQUEST['day'], '29') ?>>29</option>
<option value="30" <?php selectedIf(@$_REQUEST['day'], '30') ?>>30</option>
<option value="31" <?php selectedIf(@$_REQUEST['day'], '31') ?>>31</option>
</select>
<select  name="year">
<option selected="selected">Select One</option>
<option value="2016" <?php selectedIf(@$_REQUEST['year'], '2016') ?>>2016</option>
<option value="2017" <?php selectedIf(@$_REQUEST['year'], '2017') ?>>2017</option>
<option value="2018" <?php selectedIf(@$_REQUEST['year'], '2018') ?>>2018</option>
<option value="2019" <?php selectedIf(@$_REQUEST['year'], '2019') ?>>2019</option>
<option value="2020" <?php selectedIf(@$_REQUEST['year'], '2020') ?>>2020</option>
</select>
       </div>
     </div>
    </div>
  </div>
  <div class="panel panel-default ">
    <div class="panel-heading" role="tab" id="headingOne" data-toggle="collapse" data-parent="#accordion" data-target="#collapseOne" aria-expanded="false" aria-controls="collapseOne">
      <h4 class="panel-title"><a class="accordion-toggle">Oilfield Haulers Quiz Module 3: Crane and Truck Mounted Crane Operations</a>
      </h4>
    </div>
    <div id="collapseOne" class="panel-collapse collapse in" role="tabpanel" aria-labelledby="headingOne">
   <div class="panel-body">
 
 <div class="form-group">
<label for="question_1">1.    You have noticed that the crane you're working with doesn't have a capacity chart.  What should you do?</label>
<select  name="question_1" class="form-control">
<option selected="selected">Select One</option>
<option value="A. Work very carefully." <?php selectedIf(@$_REQUEST['question_1'], 'A. Work very carefully.') ?>>A.    Work very carefully.</option>
<option value="B. Do not work with it." <?php selectedIf(@$_REQUEST['question_1'], 'B. Do not work with it.') ?>>B.    Do not work with it.</option>
<option value="C. Only lift light loads." <?php selectedIf(@$_REQUEST['question_1'], 'C. Only lift light loads.') ?>>C.    Only lift light loads.</option>
<option value="D. Operate as usual; cranes do not have capacity charts." <?php selectedIf(@$_REQUEST['question_1'], 'D.    Operate as usual; cranes do not have capacity charts.') ?>>D. Operate as usual; cranes do not have capacity charts..</option>

</select> </div>
     <div class="form-group">
<label for="question_2">2.  Hazard(s) associated with crane and truck mounted crane operations include:</label>
<select  name="question_2" class="form-control">
<option selected="selected">Select One</option>
<option value="A. Damaged slings and rigging." <?php selectedIf(@$_REQUEST['question_2'], 'A. Damaged slings and rigging.') ?>>A. Damaged slings and rigging.</option>
<option value="B. Poor communication." <?php selectedIf(@$_REQUEST['question_2'], 'B. Poor communication.') ?>>B. Poor communication.</option>
<option value="C. Overhead/Suspended loads." <?php selectedIf(@$_REQUEST['question_2'], 'C. Overhead/Suspended loads.') ?>>C. Overhead/Suspended loads.</option>
<option value="D. All of the above." <?php selectedIf(@$_REQUEST['question_2'], 'D. All of the above.') ?>>D. All of the above.</option>
<option value="E. None of the above." <?php selectedIf(@$_REQUEST['question_2'], 'E. None of the above.') ?>>E.    None of the above.</option>
</select> </div>
<div class="form-group">
<label for="question_3">3.    What do you need to consider when planning a lift?</label>
<select  name="question_3" class="form-control">
<option selected="selected">Select One</option>
<option value="A. Know the limitations of the lifting equipment." <?php selectedIf(@$_REQUEST['question_3'], 'A. Know the limitations of the lifting equipment.') ?>>A.    Know the limitations of the lifting equipment.</option>
<option value="B. Select and size the rigging for the load and determine how it will be connected to the hook." <?php selectedIf(@$_REQUEST['question_3'], 'B. Select and size the rigging for the load and determine how it will be connected to the hook.') ?>>B. Select and size the rigging for the load and determine how it will be connected to the hook.</option>
<option value="C. Locate the center of gravity of the load." <?php selectedIf(@$_REQUEST['question_3'], 'C.    Locate the center of gravity of the load.') ?>>C. Locate the center of gravity of the load.</option>
<option value="D. Hold a safety meeting before starting the lift." <?php selectedIf(@$_REQUEST['question_3'], 'D. Hold a safety meeting before starting the lift.') ?>>D. Hold a safety meeting before starting the lift.</option>
<option value="E. All of the above" <?php selectedIf(@$_REQUEST['question_3'], 'E. All of the above') ?>>E.    All of the above.</option>
</select> </div>
<div class="form-group">
<label for="question_4">4.    What should you do if you don't know the weight of an object to be lifted?</label>
<select  name="question_4" class="form-control">
<option selected="selected">Select One</option>
<option value="A. Estimate the weight and proceed with caution." <?php selectedIf(@$_REQUEST['question_4'], 'A.    Estimate the weight and proceed with caution.') ?>>A. Estimate the weight and proceed with caution.</option>
<option value="B. Do not lift the load." <?php selectedIf(@$_REQUEST['question_4'], 'B.    Do not lift the load.') ?>>B. Do not lift the load.</option>
<option value="C. Lift the load with steel braided slings." <?php selectedIf(@$_REQUEST['question_4'], 'C. Lift the load with steel braided slings.') ?>>C.    Lift the load with steel braided slings.</option>
<option value="D. Lift load with a fully extended boom." <?php selectedIf(@$_REQUEST['question_4'], 'D.    Lift load with a fully extended boom.') ?>>D. Lift load with a fully extended boom.</option>
<option value="E. None of the above." <?php selectedIf(@$_REQUEST['question_4'], 'E. None of the above.') ?>>E.    None of the above.</option>
</select> </div>
<div class="form-group">
<label for="question_5">5.    Identify component(s) of a safe lifting procedure.</label>
<select  name="question_5" class="form-control">
<option selected="selected">Select One</option>
<option value="A. Designate one signal person." <?php selectedIf(@$_REQUEST['question_5'], 'A.    Designate one signal person.') ?>>A. Designate one signal person.</option>
<option value="B. Focus on speed." <?php selectedIf(@$_REQUEST['question_5'], 'B. Focus on speed.') ?>>B. Focus on speed.</option>
<option value="C. Raise the load as high as possible." <?php selectedIf(@$_REQUEST['question_5'], 'C. Raise the load as high as possible.') ?>>C. Raise the load as high as possible.</option>
<option value="D. Use a tagline wherever possible." <?php selectedIf(@$_REQUEST['question_5'], 'D. Use a tagline wherever possible.') ?>>D.    Use a tagline wherever possible.</option>
<option value="E. Both A and C" <?php selectedIf(@$_REQUEST['question_5'], 'E.    Both A and C.') ?>>E. Both A and C.</option>
<option value="F. Both A and D." <?php selectedIf(@$_REQUEST['question_5'], 'F.    Both A and D.') ?>>F. Both A and D.</option>
</select> </div>
<div class="form-group">
<label for="question_6">6.    What must be done to legally move an overweight load?</label>
<select  name="question_6" class="form-control">
<option selected="selected">Select One</option>
<option value="A. Obtain an overweight permit." <?php selectedIf(@$_REQUEST['question_6'], 'A. Obtain an overweight permit.') ?>>A. Obtain an overweight permit.</option>
<option value="B. Speed by the DOT weigh stations." <?php selectedIf(@$_REQUEST['question_6'], 'B. Speed by the DOT weigh stations.') ?>>B.    Speed by the DOT weigh stations.</option>
<option value="C. Ensure you have a pilot truck & trail vehicle." <?php selectedIf(@$_REQUEST['question_6'], 'C. Ensure you have a pilot truck & trail vehicle.') ?>>C.    Ensure you have a pilot truck and trail vehicle.</option>
<option value="D. Both A and B" <?php selectedIf(@$_REQUEST['question_6'], 'D.    Both A and B.') ?>>D. Both A and B.</option>
<option value="E. Both A and C." <?php selectedIf(@$_REQUEST['question_6'], 'E.    Both A and C.') ?>>E. Both A and C.</option>
</select> </div>
<div class="form-group">
<label for="question_7">7.    How far must a trail vehicle driver travel ahead of the load?</label>
<select  name="question_7" class="form-control">
<option selected="selected">Select One</option>
<option value="A. 50 to 100 meters ahead." <?php selectedIf(@$_REQUEST['question_7'], 'A. 50 to 100 meters ahead.') ?>>A. 50 to 100 meters ahead.</option>
<option value="B. 100 to 300 meters ahead." <?php selectedIf(@$_REQUEST['question_7'], 'B.    100 to 300 meters ahead.') ?>>B. 100 to 300 meters ahead.</option>
<option value="C. 300 to 1,000 meters ahead." <?php selectedIf(@$_REQUEST['question_7'], 'C. 300 to 1,000 meters ahead.') ?>>C.    300 to 1,000 meters ahead.</option>
<option value="D. None of the above; a trail vehicle follows the load." <?php selectedIf(@$_REQUEST['question_7'], 'D. None of the above; a trail vehicle follows the load.') ?>>D. None of the above; a trail vehicle follows the load.</option>

</select> </div>
      </div>
    </div>

  </div>
 
 


    </div></div></div>  
    
 <div class="form-group" style="margin-left:0 auto;margin-right:20%;"><input type="submit" name="add" value="Submit" id="submit"  /></div>
    
    
</form>

By dmn - October 31, 2016

Excellent, works great - thanks Ross.