html radio button value code example

Example 1: get radio button value javascript

document.querySelector('input[name="rate"]:checked').value;

Example 2: radio buttons html

<input type="radio" name="gender" value="male"> Male<br>
<input type="radio" name="gender" value="female"> Female<br>
<input type="radio" name="gender" value="other"> Other

Example 3: how to add select only one radio button in html

<input type="radio" name="nameA" id="nameA" value="nameA">
<label for="nameA">Choice A</label>
<input type="radio" name="nameB" id="nameB" value="nameB">
<label for="nameB">Choice B</label>

Example 4: radio input value

<input type="radio" name="test" id="test" value="this is the value">

Tags:

Html Example