Hi,
Could someone give me a hand please?
There is a question ('statuut') with 2 possible answers (radio button options)
If answer 1 is selected, a required text field ('riziv') should appear, if answer 2 is selected the textbox should disappear
If answer 2 is selected, a required text field ('rolnr') should appear, if answer 1 is selected the textbox should disappear
I am trying to compose the code using examples on this forum, but I can't get it to work :/
The fields are not disappearing/appearing when answer 1 or 2 is selected or changed
any help is very welcome... thanks in advance.
J
Could someone give me a hand please?
There is a question ('statuut') with 2 possible answers (radio button options)
If answer 1 is selected, a required text field ('riziv') should appear, if answer 2 is selected the textbox should disappear
If answer 2 is selected, a required text field ('rolnr') should appear, if answer 1 is selected the textbox should disappear
I am trying to compose the code using examples on this forum, but I can't get it to work :/
The fields are not disappearing/appearing when answer 1 or 2 is selected or changed
var textarea1_id, textarea1, textarea2_id, textarea2, div;
/* edit the next two lines to match the ids of the elements in your form */
textarea1_id = 'riziv';
textarea2_id = 'rolnr';
window.addEvent('domready', function() {
textarea1 = $(textarea1_id);
div1 = $(textarea1_id+'_container_div');
div1.dissolve();
showHide();
$('statuut_1').addEvent('change', showHide);
});
window.addEvent('domready', function() {
textarea2 = $(textarea2_id);
div2 = $(textarea2_id+'_container_div');
div2.dissolve();
showHide();
$('statuut_0').addEvent('change', showHide);
});
function showHide() {
if ( $('statuut_1').checked === true && $('statuut_1').checked === false ) {
div1.reveal();
textarea1.disabled = false;
div2.dissolve();
textarea2.disabled = true;
$('riziv').addClass("validate['required']");
formCheck.register($('riziv'));
textarea2.value = '';
} elseif ( $('statuut_1').checked === false && $('statuut_1').checked === true ) {
div2.reveal();
textarea2.disabled = false;
div1.dissolve();
textarea1.disabled = true;
$('rolnr').addClass("validate['required']");
formCheck.register($('rolnr'));
textarea1.value = '';
} else {
div1.dissolve();
div2.dissolve();
}
}
any help is very welcome... thanks in advance.
J