Making a new tool and require a dropdown menu but it doesn't seem to work the way I have coded it.

Not sure exactly what the problem is. Have researched online but I haven't been able to figure it out.

if(!isset($_POST["ReasonList"]))
 {
  $error .= '<p><label class="text-danger">Please select a reason</label></p>';
 }
<div class="form-group">
<label>Select Reason for Request</label>
<select id="ReasonList" name="ReasonList" class="form-control" value="<?php echo $ReasonList; ?>" />

  <option value = "">Select...</option>
  <option value = "1">Original Engineer has left the company</option>
  <option value = "2">Actively involved in field work on customer site</option>
  <option value = "3">No capacity due to customer mandated deadlines</option>
  <option value = "4">Exception request by manager</option>
</select>
</div>

If option is selected then able to submit the form. If option is not selected it will give the error in the if statement - Please select a reason

1 Answers

0
RiggsFolly On Best Solutions

See the corrected <select> element, and how a bit of code indentation make the HTML easier to read and debug.

<div class="form-group">
    <label>Select Reason for Request</label>
    <select id="ReasonList" name="ReasonList" class="form-control">
        <option value = "">Select...</option>
        <option value = "1">Original Engineer has left the company</option>
        <option value = "2">Actively involved in field work on customer site</option>
        <option value = "3">No capacity due to customer mandated deadlines</option>
        <option value = "4">Exception request by manager</option>
    </select>
</div>

The <select> element does not have a value property and you accidentally closed the <select> before the name attribute.