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
Hi tschip,
Did you check CF v5 ? it has this feature as built in!
But regarding the code you have used, you have to set ids for the checkbox and the text area and use them in the 2 lines specified!
Regards,
Max
Did you check CF v5 ? it has this feature as built in!
But regarding the code you have used, you have to set ids for the checkbox and the text area and use them in the 2 lines specified!
Regards,
Max
In V5 its under the field settings, at the "Events" tab, for example, check the checkbox group element!
Regards,
Max
Regards,
Max
This topic is locked and no more replies can be posted.
