Hi,
I up this old topic as i'm blocked concerning this feature.
It works for the first checkbox + textarea pair but for the second one which is a container of 4 text bloc i really don't arrive to do it.
The container is a custom one with
<div id="alterns_titles_container_div">
for the beginning and
</div>
at the end. (I try with just "alterns_titles" for the id, and that still doesn't work.)
The js is as mentionned in the FAQ :
var checkboxes;
window.addEvent('domready', function() {
var i, checkbox, textarea, div, textbox;
checkboxes = {};
// link the checkboxes and textarea ids here
checkboxes['altern_title_checkbox'] = 'altern_title';
checkboxes['alterns_titles_checkbox'] = 'alterns_titles';
for ( i in checkboxes ) {
checkbox = $(i);
textbox = $(checkboxes[i]);
div = $(textbox.id + '_container_div');
div.dissolve();
showHide(i);
addEventToCheckbox(checkbox);
}
function addEventToCheckbox(checkbox) {
checkbox.addEvent('click', function(event) {
showHide(event.target.id);
});
}
});
function showHide(id) {
var checkbox, textarea, div;
if(typeof id == 'undefined') {
return;
}
checkbox = $(id);
textarea = checkboxes[id];
div = $(textarea + '_container_div');
textarea = $(textarea);
if(checkbox.checked) {
div.setStyle('display', 'block');
//div.reveal();
div.setStyle('display', 'block');
textarea.disabled = false;
} else {
div.setStyle('display', 'none');
//div.dissolve();
textarea.value = '';
textarea.disabled = true;
}
}
You can find the form at this url : [no longer available, see the edit for solution]
If anybody has an idea about what i'm doing wrong.
Thanks in advance.
*****************************************************
Edit :
I checked the form that fullfusion have posted previously (
http://www.safesiteonline.com/index.php?option=com_chronoforms&chronoform=facilityregform2 ) and by using containers and his js it works.
My js is now :
var checkboxes;
window.addEvent('domready', function() {
var i, checkbox, textarea, div, textbox;
checkboxes = {};
// link the checkboxes and textarea ids here
checkboxes['altern_title_checkbox'] = 'altern_title';
checkboxes['alterns_titles_checkbox'] = 'alterns_titles';
for ( i in checkboxes ) {
checkbox = $(i);
textbox = $(checkboxes[i]);
div = $(textbox.id);
div.dissolve();
showHide(i);
addEventToCheckbox(checkbox);
}
function addEventToCheckbox(checkbox) {
checkbox.addEvent('click', function(event) {
showHide(event.target.id);
});
}
});
function showHide(id) {
var checkbox, textarea, div;
if(typeof id == 'undefined') {
return;
}
checkbox = $(id);
textarea = checkboxes[id];
div = $(textarea);
textarea = $(textarea);
if(checkbox.checked) {
div.setStyle('display', 'block');
//div.reveal();
div.setStyle('display', 'block');
textarea.disabled = false;
} else {
div.setStyle('display', 'none');
//div.dissolve();
textarea.value = '';
textarea.disabled = true;
}
}
And we need to use a custom container even for a single text box otherwise there is a space like a jump line in the form.
The container should have
<div id="as_you_want">
for beginning and
</div>
as ending.
Hope this could help somebody🙂