?
Solved

Write text to a text area from radio button

Posted on 2014-08-11
2
Medium Priority
?
230 Views
Last Modified: 2014-08-11
I have a text area and a set of 3 radio buttons.

When the user clicks a radio button, I'd like to write some text to the text area based on what they selected. Could someone assist with how to write this JavaScript? Thank you.
0
Comment
Question by:earwig75
  • 2
2 Comments
 
LVL 6

Expert Comment

by:Ravi Kalla
ID: 40253710
do you want it using javascript or jquery?
0
 
LVL 6

Accepted Solution

by:
Ravi Kalla earned 2000 total points
ID: 40253732
Below is the code
<!DOCTYPE html>
<html>
<head>
<script>
function radioChanged(color) {
//    alert(color);
    document.getElementById('txtArea').value = color;
}

</script>
</head>
<body>

  <input type="radio" name="colors" id="red" onchange="radioChanged('red')">Red<br/>
  <input type="radio" name="colors" id="blue" onchange="radioChanged('blue')">Blue<br/>
  <input type="radio" name="colors" id="black" onchange="radioChanged('black')">Black<br/>

<textarea id="txtArea" rows="4" cols="50">
</textarea>

</body>
</html>

Open in new window

0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question