/    Sign up×
Community /Pin to ProfileBookmark

writing to new doc. from textarea

Hello every one, I’m very new at this jscript stuff so any help will be greatly appreciated!

I’m trying to write the text input from a text area to a new document. This is what I have so far:

<SCRIPT type=”text/javascript”>

function create()
{

dothis = new Date()

month = dothis.getMonth()

month = (month * 1) + 1

day = dothis.getDate()

year = dothis.getFullYear()

ow=window.open()

go=ow.document.write

b=” “+month+”/”+day+”/”+year+”<br>”

go(“<HTML><HEAD><TITLE>Party On !</TITLE>”)
go(“</HEAD><BODY BGCOLOR=’#999999′ LINK=’#0000FF’ VLINK=’#0000cc’>”)
go(“<HR WIDTH=100%>”)
go(“<TR><TD WIDTH=550 BGCOLOR=#FFFFFF>”)
go(b+document.form1.ta.value)
go(“</TD></TR></TABLE>
go(“</CENTER></BODY></HTML>”)

}

</SCRIPT>

<form name=”form1″ action=””>
<textarea name=”ta” cols=”60″ rows=”40″></textarea>
<input type=”Button” value=”update” onclick=”create()”>
</form>

Keep getting error “document.form1.ta” undefined.

????????????????????

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@Paul_JrFeb 23.2004 — Hmmm... Try this
[size=1]
&lt;script type="text/javascript"&gt;
//&lt;![CDATA[
function create() {
var now = new Date();
var month = now.getMonth();
var month = (month * 1) + 1;
var day = now.getDate();
var year = now.getFullYear();
var date = " "+month+"/"+day+"/"+year+"&lt;br /&gt;";

var win = window.open();

win.document.write('&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"&gt; n');
win.document.write('&lt;html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"&gt;n');
win.document.write('&lt;head&gt;&lt;title&gt;Example&lt;/title&gt;n');
win.document.write('&lt;meta http-equiv="Content-Type" content="application/xhtml+xml; charset=iso-8859-1" /&gt;nn');
win.document.write('&lt;/head&gt;n');
win.document.write('&lt;body style="background-color: #999;"&gt;nn');
win.document.write('&lt;hr /&gt;n');
win.document.write('&lt;div style="width: 550px; background-color: #FFF; padding: 10px;"&gt;'+date+document.forms[0]['myinput'].value+'&lt;/div&gt;nn');
win.document.write('&lt;/body&gt;n');
win.document.write('&lt;/html');
}
//]]&gt;
&lt;/script&gt;
... ... ...
&lt;form action="#" onsubmit="return create();"&gt;
&lt;div&gt;
&lt;textarea name="myinput" cols="95" rows="20"&gt;&lt;/textarea&gt; &lt;br /&gt;
&lt;input type="submit" value="Update" /&gt;
&lt;/div&gt;
&lt;/form&gt;
[/size]

Hehehe, I've never actually done this before, just seen it done, so lemme know if it works for you.
Copy linkTweet thisAlerts:
@fredmvFeb 23.2004 — &lt;script type="text/javascript"&gt;
//&lt;![CDATA[
function generateDocument(content)
{
var w = window.open('', '', 'height=500,width=550');

<i> </i> with(w.document)
<i> </i> {
<i> </i> write(content);
<i> </i> close();
<i> </i> }
<i> </i>}
//]]&gt;
&lt;/script&gt;
&lt;form action="#"&gt;
&lt;div&gt;
&lt;input type="button" value="Create Window" onclick="generateDocument('The current date/time is: ' + new Date());" /&gt;
&lt;/div&gt;
&lt;/form&gt;
×

Success!

Help @drumm spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.22,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...