mercredi 1 juillet 2015

Submit an input box OR a select box (not both)

I want to have the option for my users to submit a form that they have the option to either use either the select box or the input text box, but not both. Here is my form code:

    <!-- Text input-->
    <div id="incident-type" class="control-group">
      <label class="control-label" for="textinput">Incident Type (Use this box or the common incident box)</label>
      <div class="controls">
        <input id="textinput" name="incident_type" type="text" class=" form-control">
      </div>

    </div>  

<!-- Select Box -->
           <div id="incident-control-box" class="control-group">
      <label class="control-label" for="textinput">Common Incidents (Use this box or the incident type box)</label>
      <div class="controls">
        <select onclick="hideInputBox()" id="textinput incident-type1" name="incident_type" type="text" class=" form-control" >
            <option value="blank"></option>
      <option value="AFA Commercial">AFA Commercial</option>
      <option value="AFA Residential">AFA Residential</option>
      <option value="MVA W/Injuries">MVA W/Injuries</option>
      <option value="Gas Leak Outside">Gas Leak Outside</option>
      <option value="Gas Leak Inside">Gas Leak Inside</option>
      <option value="Investigation">Investigation</option>
      <option value="Possible Structure Fire">Possible Structure Fire</option>

          </select>
      </div>

    </div>

Then here is my code from my PHP where it gets the input boxes of the form:

  $incident_type     = $row['incident_type'];

The problem I run into is that I want either one of them to submit depending on what the user chooses to fill out. Currently only the select input works, not the text box input also.

Aucun commentaire:

Enregistrer un commentaire