Using radio buttons is the best solution as per @sidâs answer.
You can style the radio buttons as normal buttons using the following style rules
<style>
.questionaire {
margin: 10px;
}
.questionaire input[type="radio"] {
opacity: 0;
position: fixed;
width: 0;
}
.questionaire label {
display: inline-block;
padding: 10px 20px;
font-family: sans-serif, Arial;
font-size: 16px;
border: 2px solid #444;
border-radius: 4px;
}
.questionaire label.green {
background-color: green;
color: white;
}
.questionaire label.orange {
background-color: orange;
}
.questionaire label.grey {
background-color: grey;
color: white;
}
.questionaire label.red {
background-color: red;
color: white;
}
.questionaire label:hover {
background-color: #dfd;
}
.questionaire input[type="radio"]:focus+label {
border: 2px dashed #444;
}
.questionaire input[type="radio"]:checked+label {
background-color: aqua;
color: black;
border-color: #4c4;
}
</style>
The html will look like
<form action="dmxConnect/api/questionaire.php" id="frmQuestionaire" is="dmx-serverconnect-form" dmx-on:success="notifies1.success('\'yes, you have done it.\'')">
<div class="col-12 mt-4 questionaire">
<p>1. What do you think of the WHO</p>
<input type="radio" name="who" id="who1" value="good" checked="true">
<label for="who1" class="green">Good</label>
<input type="radio" name="who" id="who2" value="fix">
<label for="who2" class="orange">Need Fixing</label>
<input type="radio" name="who" id="who3" value="nogood">
<label for="who3" class="grey">Not Good</label>
<input type="radio" name="who" id="who4" value="bad">
<label for="who4" class="red">Bad</label>
</div>
<div class="col-12 mt-4 questionaire">
<p>2. What do you think of NATO</p>
<input type="radio" name="nato" id="nato1" value="good" checked="true">
<label for="nato1" class="green">Good</label>
<input type="radio" name="nato" id="nato2" value="fix">
<label for="nato2" class="orange">Need Fixing</label>
<input type="radio" name="nato" id="nato3" value="nogood">
<label for="nato3" class="grey">Not Good</label>
<input type="radio" name="nato" id="nato4" value="bad">
<label for="nato4" class="red">Bad</label>
</div>
<div class="col-12 mt-4 questionaire">
<p>3. What do you think of the UN</p>
<input type="radio" name="un" id="un1" value="good" checked="true">
<label for="un1" class="green">Good</label>
<input type="radio" name="un" id="un2" value="fix">
<label for="un2" class="orange">Need Fixing</label>
<input type="radio" name="un" id="un3" value="nogood">
<label for="un3" class="grey">Not Good</label>
<input type="radio" name="un" id="un4" value="bad">
<label for="un4" class="red">Bad</label>
</div>
<div class="col-12 mt-5">
<button class="btn btn-primary" type="submit">Submit</button>
</div>
The result where aqua coloured buttons are those that are selected