Using a radio button to generate text

This might be an easy one. I’m looking to generate text in a simple HTML text box by using a radio button. The concept goes as this:

User input
Choose a color:
(*) Blue () Red () Yella’ <—simulated radio buttons w/ blue selected

Output

My favorite color is Blue

^— simulated text box with resulting output

In other words, the radio button selected would generate the underlined word within the sentence in ‘real-time’ in a text box below the radio buttons. Is this do-able? Thanks!

This should be what your looking for

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script type="text/javascript">
function setColor(color) {
    var msg  = 'My favorite color is ';
    var form = document.forms['myform'];
    
    form.myColor.value = msg + color;
}
</script>
</head>
<body>

<form action="" method="post" id="myform">
    <label for="blue">Blue:<label>
    <input type="radio" name="color" value="Blue" id="blue" onclick="setColor(this.value)" />
    <label for="red">Red:<label>
    <input type="radio" name="color" value="Red" id="red" onclick="setColor(this.value)" /><br /><br />
    Color: <input type="text" name="myColor" value="" size="35" />
</form>

</body>
</html>

Awesome, SgtLegend! Thanks a million! That’s just what I’m looking for. I will be able to use this. Thanks for the help!

Your very welcome