Show certain values in a textfield based on checkbox input
Hello,
Javascript is not really my cup of tea, so I'm hoping someone here is able to help me out with this problem.. In the form I'm creating, it is needed that a certain value is shown in a certain textfield based on which checkbox is marked. There are 4 checkboxes (CheckBoxWarranty, CheckBoxWarranty1, CheckBoxWarranty2, CheckBoxWarranty3). This is set up in a way that the user only can check 1 checkbox (it is not possible to check multipe checkboxes). But depending on which checkbox is marked, a certain value need to be shown in the textfield Result. Below you'll find a overview of which value that needs to be shown for each checkbox.
CheckBoxWarranty = 10
CheckBoxWarranty1 = 12
CheckBoxWarranty2 = 15
CheckBoxWarranty3 = 20
Based on other discussions, I was already able to make this work for 1 checkbox with the following code as a custom calculation script for the textfield.
event.value = (this.getField("CheckBoxWarranty").valueAsString=="Off")? "" : "10";
But I don't really know how to go further from here. I already tried adding the same lines for the other checkboxes to the code. But tthis result in always showing the results for the first line, I assume the first line simply overwrites the others. I assume this needs some conditional-statements? So some help here would really be appreciated.
Thanks in advance.
