Hyena
New Member
I have a checkbox (one) in a form (with value '2', when checked). If the checkbox is checked, values in other formfields should change. And when the checkbox is unchecked the values should change back to the original number. I also would like the put enable to 'no' when the checkbox is selected. I first wanted to focus on changing the value in the target field, but I don't seem to be able to read the value of the checkbox. So I put in JS in the checkbox element (publish: Yes and event: click):
I looked into the form PHP plugin, but I think this is better approached with JS? So far I have only done some simple calculations with JavaScript. I tried to use what I could find on the wiki pages, ... but can't get it to work.
var inherit = Fabrik.getBlock('form_7').formElements.get('fab_gezinsweekend___Tweepersoonkamer.value').getValue();
if (inherit == '2')
{
$('fab_gezinsweekend___min18').value = 0;
$('fab_gezinsweekend___plus18').value = 2;
$('fab_gezinsweekend___Prijsplus18').value = 95;
} else {
$('fab_gezinsweekend___min18').value = 0;
$('fab_gezinsweekend___plus18').value = 1;
$('fab_gezinsweekend___Prijsplus18').value = 85;
}
What is wrong here?if (inherit == '2')
{
$('fab_gezinsweekend___min18').value = 0;
$('fab_gezinsweekend___plus18').value = 2;
$('fab_gezinsweekend___Prijsplus18').value = 95;
} else {
$('fab_gezinsweekend___min18').value = 0;
$('fab_gezinsweekend___plus18').value = 1;
$('fab_gezinsweekend___Prijsplus18').value = 85;
}
I looked into the form PHP plugin, but I think this is better approached with JS? So far I have only done some simple calculations with JavaScript. I tried to use what I could find on the wiki pages, ... but can't get it to work.