/    Sign up×
Community /Pin to ProfileBookmark

setting value of textarea

How is this done? I have tried two methods but neither are working for me.

document.AssessResult.formText.value = ‘hello’

document.getElementById(‘textArea’).innerHTML = ‘hello’

to post a comment
JavaScript

7 Comments(s)

Copy linkTweet thisAlerts:
@CharlesJun 22.2009 — Please post a link to the troublesome document.
Copy linkTweet thisAlerts:
@KDLAJun 22.2009 — document.form.getElementbyID("textareaID").value = 'hello'

(insert appropriate id)

or

<textarea>Value</textarea>
Copy linkTweet thisAlerts:
@hacketauthorJun 22.2009 — Javascript:

document.getElementById("textArea").value = 'value'

HTML:

<body class="oneColElsCtr">

<form id="resultForm" name="AssessResult" method="post" action="" onsubmit="">

<div id="container">

<div id="mainContent">

<h1>Your Results by Category</h1>

<p>1=Strongly Disagree, 2=Disagree, 3=Neither, 4=Agree, 5=Strongly Agree</p>

<label>

<textarea name="formText" id="textArea" cols="100" rows="50">

</textarea>

</label>


</td>

</tr>

</table>

<p align="center">

<label>

<input type="submit" name="submitForm" id="submitForm" value="Submit"/>

</label>

</p>


I have a whole bunch of js functions as well, but they shouldn't be affecting this. I commented them out. I don't get it. Thanks
Copy linkTweet thisAlerts:
@CharlesJun 22.2009 — document.form.getElementbyID("textareaID").value = 'hello'[/QUOTE]That's kind of a DOM level 0 / DOM level 1 hybrid, not that there is anything wrong with that. [i]// DOM level 0[/i]

document.forms[0].[i]textareaName[/i].value = 'hello'

[i]// DOM level 1[/i]

document.getElementById ('[i]textareaID[/i]').appendChild (document.createTextNode ('hello'))
The level 0 method can be further simplified but I would have to see the context.
Copy linkTweet thisAlerts:
@CharlesJun 22.2009 — Where are you trying to write to the textarea?
Copy linkTweet thisAlerts:
@hacketauthorJun 22.2009 — Actually I'm going to change where I'm going with this. What I'm attempting to do is call the 'SaveAs' dialouge box so that when a person hits a button on my site, it will prompt them into saving the page. However, all the info on the page is contained in JS variables and so it all disappears when I open the saved page.

What I was trying to do is save all the values into a textarea, but I can see this will be clumsy at best.

Does anyone know of a way to change all the values in the variables to 'savable HTML'....if you know what I mean?
Copy linkTweet thisAlerts:
@hacketauthorJun 22.2009 — Nevermind I solved it. Just called a window.print() function and then have the user select PDF Print to save a soft copy. It's a lot easier than what I was doing.
×

Success!

Help @hacket 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.18,
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,
)...