Input Radio value Property - Using radio buttons together with a text input field to display the value of the selected radio button: - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Input Radio

Description

Input Radio value Property - Using radio buttons together with a text input field to display the value of the selected radio button:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<p>Select your favorite browser:</p>
<form action="#">
  <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  ww w.  ja  v  a2 s  . c om*/

<script>
function myFunction(browser) {
    document.getElementById("result").value = browser;
}
</script>

</body>
</html>

Related Tutorials