By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,819 Members | 1,459 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,819 IT Pros & Developers. It's quick & easy.

how do you display values in a textarea using javascript

P: 12
How do you display values in a textarea using javascript.

ex. i have 2 radio buttons

o Adult =$9.99
o Child =$6.99

i need it to be, so that if i select adult in the radio button option , it will display 9.99 in my textarea at the other frame. Cause im using 2 frames for this html file. The radio buttons are at the left frame and the textarea is at the right frame.
Dec 6 '06 #1
Share this Question
Share on Google+
1 Reply


acoder
Expert Mod 15k+
P: 16,027
Expand|Select|Wrap|Line Numbers
  1. function setTextAreaVal(val) {
  2.     //First of all, you need to access the right frame.
  3.     //assuming the name of the frame is "right".
  4.     var frame = top.right;
  5.     // Then you need to access the textarea.
  6.     //If using the ID
  7.     var textarea = document.getElementById("textarea");
  8.     //Alternatively, if using the name, you also need the form name, e.g.
  9.     //var textarea = document.forms[formname].elements[textareaname];
  10.     //Finally, set the value using the value property.
  11.     textarea.value = val;
  12. }
Call the function onclick, e.g. onclick="setTextAreaVal(this.value)".
Jun 2 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.