Link to home
Start Free TrialLog in
Avatar of tanc02
tanc02

asked on

How do I read textarea value ?

How do I read textarea value ?
Avatar of fritz_the_blank
fritz_the_blank
Flag of United States of America image

What do you mean? If you have a form named SomeForm and a textarea named SomeTextArea, you can access the value by:

strText=document.SomeForm.SomeTextArea.value
Avatar of tanc02
tanc02

ASKER

but I got object required error.
Avatar of tanc02

ASKER

Sorry ! It is object expected.

Here is my code :

<form name="SomeForm">
<textarea name="SomeTextArea" rows=5 cols=50 onChange="javascript:setFlag()"></textarea>
<input type="button" value="Submit" onClick="tell()">
</form>

<script>
function tell(){
alert(document.SomeForm.SomeTextArea.value);
}
</script>
ASKER CERTIFIED SOLUTION
Avatar of fritz_the_blank
fritz_the_blank
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Is that everything in the page?

Provide us with the whole page as there may be errors elsewhere having a knock-on effect.

Ant
Avatar of tanc02

ASKER

My mistake, I should not have setflag function.
Paste this in to a page and you will see it works

<html>
<head>
<script language="javascript">
function tell(){
  alert(document.SomeForm.SomeTextArea.value);
}
</script>
</head>
<body>
<form name="SomeForm">
<p><textarea name="SomeTextArea">hello!</textarea></p>
<p><input type="button" value="click me!" onclick="tell();"></p>
</form>
</body>
</html>

It could be a problem with the setFlag() as fritz mentions.

We really need to see the whole page

:o)

Ant
Glad you sorted it.

:o)

Ant