checkbox to change form field content

Status
Not open for further replies.

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):
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?
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.
 
Take the .value off the end of 'fab_gezinsweekend___Tweepersoonkamer.value'.

Instead of using $() ...

Code:
$('fab_gezinsweekend___min18').value = 0;

... do ...

Code:
Fabrik.getBlock('form_7').formElements.get('fab_gezinsweekend___min18').update('0');

-- hugh
 
Status
Not open for further replies.
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top