/ Published in: JavaScript
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<html> <head> <title>Radio Test</title> <script type="text/javascript"> function setText(target) { var txt = document.getElementById(target); var temp = txt.value; var tf = document.getElementById("textField"); tf.value = temp; } </script> </head> <body> <form id="radioform" action=""> <input id="radio1" type="radio" name="r1" value="Okay" onClick="setText('radio1');" />Yes <br/> <input id="radio2" type="radio" name="r1" value="Nope" onClick="setText('radio2');" />No <br/> <input type="hidden" id="textField" type="text" name="text" value="Choose One" /> </form> <body/> </html>