Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Javascript Textarea innerHTML with Netscape 7.1 1

Status
Not open for further replies.

LTeeple

Programmer
Aug 21, 2002
362
CA
Hi all,

I have some text displayed in a textarea, drawn from a database using php, and put into the textarea using JS (a dynamic form scenario):
Code:
document.form.edit_place_address.innerHTML = value;
On this form, I want the user to be able to change the value in the textarea field. It works perfectly in IE. In NN7.1, when the user clicks on the textarea field in question, the cursor starts at the beginning, and when the user starts typing, the characters are simply overwriting what's already there. Also, the user cannot highlight the text, nor move the cursor. The only option is to overwrite the existing value.

I attempted to populate the text area field using:
Code:
document.form.edit_place_address.value = value;
however, the data wasn't appearing. I read somewhere that there is no 'value' for textarea, just innerHTML. Is this true? Can someone suggest a workaround?

Thank you!

[cheers]
Cheers!
Laura
 
Laura,

I just created a test and it worked fine. I have a feeling it's not working for you because "value" is a reserved word. Take a look:

Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
	"[URL unfurl="true"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">[/URL]

<html>
<head>
<title>Untitled</title>

<script type="text/javascript"><!--
function fillTA(o) {
    var myVal = 'blah blah blah';
    o.value = myVal;
}
//--></script>
</head>

<body>

<form name="f">
    <textarea name="ta" rows="10" cols="10"></textarea>
    <input type="button" name="b" onclick="fillTA(this.form.ta);" />
</form>

</body>
</html>

*cLFlaVA
----------------------------
[tt]your mom goes to college[/tt]
[URL unfurl="true"]http://www.coryarthus.com/[/url]
[banghead]
 
I would use this syntax:

Code:
document.forms['yourFormName'].elements['edit_place_address'].value = 'some text';

However, don't name your form "form" (as you seem to have done).

Hope this helps,
Dan

[tt]D'ya think I got where I am today because I dress like Peter Pan here?[/tt]
[banghead]

 
Thank you BillyRayPreachersSon.

I followed your advice, changed my form name, and referred to the form objects using elements['objectname'].

Works perfectly now :)

Thank you too, cLFlaVA for taking the time to create your own test scenario.

[cheers]
Cheers!
Laura
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top