xFactorSchool.com
Python
JavaScript
How to Do Examples
C Examples
Python Examples
HTML Examples
Code Examples
C Code Examples
C++ Code Examples
C# Code Examples
Java Code Examples
Python Code Examples
HTML Code Examples
CSS Code Examples
JavaScript Code Examples
Online Compilers
C Compiler
C++ Compiler
C# Compiler
Java Compiler
Python Compiler
HTML Code Editor
CSS Code Editor
JavaScript Compiler
JavaScript Code Editor
Practice how to create radio buttons in an HTML page
HTML Online Editor
Run Code
More HTML Sample Codes
<!DOCTYPE html> <html> <head> <title>Form in HTML Page</title> <!-- Title of the page--> </head> <body> <h1>Example of Form in a Webpage</h1> <hr /> <h3>This is an HTML form.</h3> <p>Select a programmimg language and click the "Submit" button to see the effect.</p> <!--<form> tag is used to create a form. --> <form> <!--type="radio" is used to create radio button. --> <input type="radio" id="option1" name="pName" value="Python"> <!--for="option1" is used to link label with corresponding option1 radio button. --> <label for="option1">Python</label><br/> <input type="radio" id="option2" name="pName" value="Java"> <label for="option2">Java</label><br/> <input type="radio" id="option3" name="pName" value="C#"> <label for="option3">C#</label><br/> <br/> <input type="submit" id="btnSubmit" value="Submit Program" /> </form> <p><input> tag with type="radio" attribute is used to create a radio button. </p> <!--JavaScript function is used to display your selection. --> <script> var btnSubmit = document.querySelector("#btnSubmit"); btnSubmit.addEventListener('click', function (e) { e.preventDefault(); var name = document.getElementsByName("pName"); for (var i = 0; i < name.length; i++) { if (name[i].checked) { alert("You have submitted " + name[i].value); break; } } }) </script> </body> </html>