Donate SIGN UP

Javascript write text

Avatar Image
Wix | 15:54 Thu 17th Jul 2008 | Technology
4 Answers
I need to write a line of text to a textarea on my form. I've tried loads of examples and non of them work!

Please help me, it needs to be in javascript.
Gravatar

Answers

1 to 4 of 4rss feed

Best Answer

No best answer has yet been selected by Wix. Once a best answer has been selected, it will be shown here.

For more on marking an answer as the "Best Answer", please visit our FAQ.
1) surround your text area with <span id="SpanArea"> this is my text area</span>

2) Stcik something like this at the top of the page

<script type="text/javascript">

function WriteText()
{
document.**************("SpanArea").innerText =
"I want this to appear in my text area.";
}

</script>

3) put it behind a button or somthing do when button is clicked the text will appear, using something like:

<input type="button" value="Write to SPAN" onclick="WriteText()"/>



heres the whole html,

you should be able to work it out from here:


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Pants Page</title>
<meta name="vs_defaultClientScript" content="JavaScript">
<script type="text/javascript">

function WriteText()
{
document.**************("SpanArea").innerText =
"Here is a text string written to the page.";
}

</script>
</head>
<body MS_POSITIONING="GridLayout">
<TABLE height="337" cellSpacing="0" cellPadding="0" width="501" border="0" ms_2d_layout="TRUE">
<TR vAlign="top">
<TD width="10" height="15"></TD>
<TD width="190"></TD>
<TD width="301"></TD>
</TR>
<TR vAlign="top">
<TD height="25"></TD>
<TD colSpan="2">
<input type="button" value="Write to SPAN" onclick="WriteText()" ID="Button1" NAME="Button1"></TD>
</TR>
<TR vAlign="top">
<TD colSpan="2" height="297"></TD>
<TD>
<TABLE id="Table1" height="296" cellSpacing="1" cellPadding="1" width="300" border="1">
<TR>
<TD></TD>
<TD></TD>
<TD></TD>
</TR>
<TR>
<TD></TD>
<TD><span id="SpanArea">when i click button this text will change</span></TD>
<TD></TD>
</TR>
<TR>
<TD></TD>
<TD></TD>
<TD></TD>
</TR> <
seems to have chopped this bit off at the end

TABLE>
</TD>
</TR>
</TABLE>
</body>
</html>
Question Author
Thanks a lot that works great!

1 to 4 of 4rss feed

Do you know the answer?

Javascript write text

Answer Question >>

Related Questions

Sorry, we can't find any related questions. Try using the search bar at the top of the page to search for some keywords, or choose a topic and submit your own question.