how do you display values in a textarea using javascript

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • snipersix
    New Member
    • Nov 2006
    • 12

    how do you display values in a textarea using javascript

    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.
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    [code=javascript]function setTextAreaVal( val) {
    //First of all, you need to access the right frame.
    //assuming the name of the frame is "right".
    var frame = top.right;
    // Then you need to access the textarea.
    //If using the ID
    var textarea = document.getEle mentById("texta rea");
    //Alternatively, if using the name, you also need the form name, e.g.
    //var textarea = document.forms[formname].elements[textareaname];
    //Finally, set the value using the value property.
    textarea.value = val;
    }[/code]Call the function onclick, e.g. onclick="setTex tAreaVal(this.v alue)".

    Comment

    Working...