Reputation: 1
I am not able to access values of multiple radio button groups and pass those values to the backend.
<vaadin-radio-group theme="vertical" name="radio1">
<label>Staff were friendly and helpful </label>
<vaadin-radio-button value="25" label="Yes" ></vaadin-radio-button>
<vaadin-radio-button value="26" label="No" ></vaadin-radio-button>
</vaadin-radio-group><br>
<vaadin-radio-group theme="vertical" name="radio2" >
<label>Staff informed you when your car was ready </label>
<vaadin-radio-button value="27" label="Yes" ></vaadin-radio-button>
<vaadin-radio-button value="28" label="No" ></vaadin-radio-button>
</vaadin-radio-group>
I need to display the selected value for both radio1 and radio2 in the log.
submitButton.addEventListener('click', (event) => {
event.preventDefault();
let selectedValue;
for (let i = 0; i < radioButtons.length; i++) {
if (radioButtons[i].checked) {
selectedValue = radioButtons[i].value;
break;
}
}
Upvotes: 0
Views: 111