dimanche 17 mars 2019

What I would like to achieve is that when the user clicks on a checkbox that the corresponding option is auto selected

I suspect this has been answered before but I cannot find a solution, I apologise in advance!

I have the following form with various checkbox inputs and a select box with various options.

What I would like to achieve is that when the user clicks on a checkbox that the corresponding option is auto selected.

Examples: When the user clicks on the 'input' with value="Boat Available" then the 'option' with value="1" is selected.

When the user clicks on the 'input' with value="Spaces Available" then the 'option' with value="3" is selected.

Here is the form:

<form>
  <input name="title" type="checkbox" class="formElements" id="title1" value="Boat Available">Boat Available
  <input name="title" type="checkbox" class="formElements" id="title2" value="Spaces Available">Spaces Available
  <input name="title" type="checkbox" class="formElements" id="title3" value="Fully Booked">Fully Booked
  <input name="title" type="checkbox" class="formElements" id="title4" value="Not Available">Not Available
  <input name="title" type="checkbox" class="formElements" id="title5" value="Short Trip">Short Trip
  <input name="title" type="checkbox" class="formElements" id="title6" value="Trip Cancelled">Trip Cancelled
</form>

Here is the Select Box:

<select name="epcCat[1]" class="formElements" id="category">
  <option id="101" value="1">Boat Available</option>
  <option id="103" value="3">Spaces Available</option>
  <option id="104" value="4">Fully Booked</option>
  <option id="105" value="5">Not Available</option>
  <option id="10204" value="204">Short Trips</option>
  <option id="10180" value="180">Trip Cancelled</option>
</select>




Aucun commentaire:

Enregistrer un commentaire