Results 1 to 3 of 3

Thread: Pass text script adaptation.

  1. #1
    Join Date
    Jun 2006
    Location
    Carmona, Seville, Spain.
    Posts
    66
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Default Pass text script adaptation.

    About 2 years back jscheuer (I believe it was) helped me put together a script to send text from one textarea to another from one frame to another in the same frameset. The text has been extremely useful to me and I thank you.

    What I would like is a small adaptation made so that the text sent does NOT overwrite any text that might be in the receiving textarea. Preferably, it would also leave one space between the phrases too.

    Eg. If I send "I'm fine thanks." to a text area which already contains "How are you?" The result is:

    "How are you? I'm fine thanks."

    This is the original script...

    BELOW SCRIPT SENDS TEXT FROM TEXTAREA IN RIGHT FRAME TO TEXTAREA (CALLED "MSG1" IN FORM "PHRASES") IN LEFT FRAME VIA BUTTON CLICK. ANY PREVIOUS TEXT IN TEXTAREA MSG1 WILL BE OVERWRITTEN.

    THIS CODE IN BODY OF LEFT FRAME:
    <form name="phrases" form onsubmit="if(this.elements['complete_letter'].value != '') this.elements['complete_letter'].value += ' ';for(var i=0;i<this.elements.length;i++) if(this.elements[i].className.indexOf('es') != -1) this.elements['complete_letter'].value += (i == 0 ? '' : ' ') + this.elements[i].value;return false;" action="">

    THIS CODE ON BUTTON OF TEXTAREA IN RIGHT FRAME:
    <input type=button value=">" onClick="parent.passText(this.form.op.value);>

    THIS CODE IN FRAMESET CODE:
    function passText(str)
    {top.frames['left'].document.phrases.msg1.value = str;}

    Is this possible?

  2. #2
    Join Date
    Dec 2008
    Location
    Portsmouth, UK
    Posts
    1,891
    Thanks
    2
    Thanked 441 Times in 435 Posts

    Default

    Code:
    function passText(str)
    {top.frames['left'].document.phrases.msg1.value += str;}

  3. #3
    Join Date
    Jun 2006
    Location
    Carmona, Seville, Spain.
    Posts
    66
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Thumbs up Resolved. many thanks.

    That simple eh? Thanks, that's great.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •