Hi guys,
i work with the code from this url:
http://www.chronoengine.com/faqs/58-cfv4/cfv4-elements-and-html/2645-how-can-i-showhide-a-textarea-when-a-checkbox-is-clicked.html
but i have no success. i don´t understand which words or lines i have to replace.
/* edit the next two lines to match the ids of the elements in your form */
checkbox_id = 'checkbox';
textarea_id = 'textarea';
my checkbox is named checkbox18
my textarea is named textarea21.
So can you tell me the right code ? Is it like that ? :
var checkbox_id, textarea_id, checkbox, textarea, div;
/* edit the next two lines to match the ids of the elements in your form */
checkbox_id = 'checkbox18';
textarea_id = 'textarea21';
window.addEvent('domready', function() {
checkbox = $(checkbox_id);
textarea = $(textarea_id);
div = $(textarea_id+'_container_div');
div.dissolve();
showHide();
checkbox.addEvent('click', showHide);
});
function showHide() {
if ( checkbox.checked ) {
div.reveal();
textarea.disabled = false;
} else {
div.dissolve();
textarea.value = '';
textarea.disabled = true;
}
}
i load the js action skript into the "on load" event but nothing happened. Both the checkbox and the area appear from the beginning.
Maybe you can help me.
Thanks and greeting
tschip
i work with the code from this url:
http://www.chronoengine.com/faqs/58-cfv4/cfv4-elements-and-html/2645-how-can-i-showhide-a-textarea-when-a-checkbox-is-clicked.html
but i have no success. i don´t understand which words or lines i have to replace.
/* edit the next two lines to match the ids of the elements in your form */
checkbox_id = 'checkbox';
textarea_id = 'textarea';
my checkbox is named checkbox18
my textarea is named textarea21.
So can you tell me the right code ? Is it like that ? :
var checkbox_id, textarea_id, checkbox, textarea, div;
/* edit the next two lines to match the ids of the elements in your form */
checkbox_id = 'checkbox18';
textarea_id = 'textarea21';
window.addEvent('domready', function() {
checkbox = $(checkbox_id);
textarea = $(textarea_id);
div = $(textarea_id+'_container_div');
div.dissolve();
showHide();
checkbox.addEvent('click', showHide);
});
function showHide() {
if ( checkbox.checked ) {
div.reveal();
textarea.disabled = false;
} else {
div.dissolve();
textarea.value = '';
textarea.disabled = true;
}
}
i load the js action skript into the "on load" event but nothing happened. Both the checkbox and the area appear from the beginning.
Maybe you can help me.
Thanks and greeting
tschip