Skip to main content

Problem with TEXTAREA in some browsers

2 replies [Last post]
battlesjn
Offline
Joined: 2012-03-04
Points: 0

Not a java programmer. I have been struggling with copying data between two TEXTAREAs. I am trying to copy everything from textarea1 to textarea2.

Code:

function copyText()
{
var a = document.getElementById("textarea1");
var b = document.getElementById("textarea2");

if (a != null)
{
b.value = a.value;
}
}

This routine works perfectly in my HTML-Kit developer/browser and IE, but will not work in Firefox, Opera. I know that it is hitting the function because it hangs there and the next function doesn't execute (disabled buttons never enable). Does anyone know a solution for these two browsers?

Thanks.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
battlesjn
Offline
Joined: 2012-03-04
Points: 0

Finally figured out a way to do it with Firefox:

function copyEText()

{ var a = document.getElementById("textarea1");

if (a != null) {

document.cipher.textarea2.value=a.value;

}

}

textarea2 now = textarea1

battlesjn
Offline
Joined: 2012-03-04
Points: 0

Well, the above wouldn't work for some reason when I tried using it with 3 textareas. The following worked with all textareas:

function copyCTText()
{
document.cipher.text.value=document.form1.ciphertext.value;
}

function copyTPText()
{
document.form1.plaintext.value=document.cipher.text.value;
}