/    Sign up×
Community /Pin to ProfileBookmark

How to add checkbox value to textarea?

Hi,

[code]
function ck()
{
//ft.Content.value += ft.ck.value;
//ft.getElementById(‘Content’).value += ft.getElementById(‘ck’).value;
ft.getElementById(‘Content’).innerHTML += ft.getElementById(‘ck’).value;
}

<textarea id=”Content” name=”Content” rows=”5″ cols=”20″></textarea>

<INPUT id=”ck” onclick=”ck()” type=”checkbox” value=”Hello World”>
[/code]

I want the checkbox value “Hello World” to be appended to textarea by the above js.

However, it said the object does not support this attribute or method.

I guess the textarea does not support value. If so, how should I do it?

Thanks

?

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@fredmvMar 30.2004 — Welcome to the forums.&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;

&lt;html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"&gt;
&lt;head&gt;
&lt;title&gt;untitled&lt;/title&gt;
&lt;meta http-equiv="content-type" content="application/xhtml+xml; charset=iso-8859-1" /&gt;
&lt;script type="text/javascript"&gt;
//&lt;![CDATA[
function appendValue(t, v)
{
t.value += v;
}
//]]&gt;
&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;

<i> </i> &lt;form action="#"&gt;
<i> </i> &lt;textarea rows="10" cols="50"&gt;&lt;/textarea&gt;
<i> </i> &lt;input type="checkbox" value="Hello, World!" onclick="if(checked) appendValue(elements[0], value);" /&gt;
<i> </i> &lt;/form&gt;
<i> </i>&lt;/body&gt;
&lt;/html&gt;
Copy linkTweet thisAlerts:
@steelersfan88Mar 30.2004 — Since we are saying Hello to the World ?, maybe you'll know this fred. Why do so many sources list the Hello, World! with and so many without the comma.
Copy linkTweet thisAlerts:
@fredmvMar 30.2004 — Just different preferences, I guess. Though, traditionally, "Hello, World" is the first program someone writes when learning a new language.
Copy linkTweet thisAlerts:
@keroauthorMar 31.2004 — Hi,

I would like to know how can the textarea onchange be called by js.

e.g. When I click the checkbox, add value to textarea, textarea can detect it is changed (like refresh). Because I have another js to count the number of words in the textarea.

I put document.Content.onchange in last line of the js.
<i>
</i>document.getElementById('Content').value += document.getElementById('ck').value;
document.Content.onchange //how can refresh the textarea for change?

It has error.

How can I fix it?

Thanks for help.
×

Success!

Help @kero 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 6.16,
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: @nearjob,
tipped: article
amount: 1000 SATS,

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

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...