Rogier
07-04-2006, 04:42 PM
Hi all,
I am setting up a form which will ask the user for several questions after which they will then be saved to a database. It all works well with exception of one thing. I am trying the following and can't get it to work.
What I want to do is to to have multiple checkboxes, each of them activating the same textarea and then add information to the textarea.
For activating the textarea I am using the following code:
<script>
function SetState(obj_checkbox, obj_textarea){
if(obj_checkbox.checked){obj_textarea.disabled = false;}
else{ obj_textarea.disabled = true;}}
</script>
And the checkbox has the following attribute:
onclick="SetState(this,this.form.NAMEOFTEXTAREA)"
This works, however, how do I add information to the textarea when each of the checkboxes is checked? I tried obj_textarea.value='VALUE'; but this will only allow one checkbox to display its value into the textarea.
Example:
There are three checkboxes:
Checkbox 1
Checkbox 2
Checkbox 3
When checkbox 1 is checked, the textarea should be activated and read "Info 1"
When checkbox 2 is checked, information should be added to the textarea, thus reading: "Info 1, Info 2"
When checkbox 3 is checked, information should be added to the textarea, thus reading: "Info 1, Info 2, Info 3"
Now, when one of the boxes is unchecked, it would be nice if the info 1, 2 or 3 would be removed again (this is not a necessity though). If one box is checked randomly, for example only checkbox 2, the textarea should still be activated and read "Info 2".
Do you think this is possible?
Thanks in advance!
Rogier
I am setting up a form which will ask the user for several questions after which they will then be saved to a database. It all works well with exception of one thing. I am trying the following and can't get it to work.
What I want to do is to to have multiple checkboxes, each of them activating the same textarea and then add information to the textarea.
For activating the textarea I am using the following code:
<script>
function SetState(obj_checkbox, obj_textarea){
if(obj_checkbox.checked){obj_textarea.disabled = false;}
else{ obj_textarea.disabled = true;}}
</script>
And the checkbox has the following attribute:
onclick="SetState(this,this.form.NAMEOFTEXTAREA)"
This works, however, how do I add information to the textarea when each of the checkboxes is checked? I tried obj_textarea.value='VALUE'; but this will only allow one checkbox to display its value into the textarea.
Example:
There are three checkboxes:
Checkbox 1
Checkbox 2
Checkbox 3
When checkbox 1 is checked, the textarea should be activated and read "Info 1"
When checkbox 2 is checked, information should be added to the textarea, thus reading: "Info 1, Info 2"
When checkbox 3 is checked, information should be added to the textarea, thus reading: "Info 1, Info 2, Info 3"
Now, when one of the boxes is unchecked, it would be nice if the info 1, 2 or 3 would be removed again (this is not a necessity though). If one box is checked randomly, for example only checkbox 2, the textarea should still be activated and read "Info 2".
Do you think this is possible?
Thanks in advance!
Rogier