PDA

View Full Version : Resolved Pass text script adaptation.



green
02-07-2009, 06:33 PM
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?

vwphillips
02-07-2009, 07:32 PM
function passText(str)
{top.frames['left'].document.phrases.msg1.value += str;}

green
02-09-2009, 11:40 AM
That simple eh? Thanks, that's great.