Using radio buttons together with a text input field to display the value of the selected radio button:
document.getElementById("result").value = browser;
<!DOCTYPE html> <html> <body> <p>Select your favorite browser:</p> <form action="/action_page.php"> <input type="radio" name="browser" onclick="myFunction(this.value)" value="Internet Explorer">Internet Explorer<br> <input type="radio" name="browser" onclick="myFunction(this.value)" value="Firefox">Firefox<br> <input type="radio" name="browser" onclick="myFunction(this.value)" value="Opera">Opera<br> <input type="radio" name="browser" onclick="myFunction(this.value)" value="Google Chrome">Google Chrome<br> <input type="radio" name="browser" onclick="myFunction(this.value)" value="Safari">Safari<br><br> Your favorite browser is: <input type="text" id="result"> <input type="submit" value="Submit form"> </form>/*from www. j a v a 2 s . c o m*/ <script> function myFunction(browser) { document.getElementById("result").value = browser; } </script> </body> </html>