Re: Check box and append text in textarea
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.javascript archive

Re: Check box and append text in textarea

From: [on] <switchable@gmail.com>
Date: Thu Apr 13 2006 - 12:12:28 CEST

juicy wrote:
> I have create 4 check box, every check on the check box will append text in
> textarea and any uncheck on check box will remove text in text area.
>
> Please give some guide on how to control this.

Why Append/Remove ?

Seems simpler just recreating the whole "text" and setting the textarea
to it.

Warning Untested Sample Code --- Should not be used.

var output = "";
if (document.getElementById("checkbox1id").checked)
{
  output = output + "Text1";
}
if (document.getElementById("checkbox2id").checked)
{
  output = output + "Text2";
}
if (document.getElementById("checkbox3id").checked)
{
  output = output + "Text3";
}
if (document.getElementById("checkbox4id").checked)
{
  output = output + "Text4";
}

The variable "output" whould now be either "Text1Text2Text3Text4" if
all checkboxes are checked, or "Text2Text4" if only the 2nd and 4th are
checked ... and so on.

Set the value of the textarea to that and you're set, no need to
append/remove.
Received on Mon May 1 04:58:17 2006