Return to Snippet

Revision: 47513
at June 9, 2011 05:06 by kbrown


Initial Code
<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>

Initial URL

                                

Initial Description

                                

Initial Title
Populate text field in form with radio button value

Initial Tags
form, javascript

Initial Language
JavaScript