Hi,
How can I disable or modify the formula of a field using javascript?
Thanks,
Hi,
How can I disable or modify the formula of a field using javascript?
Thanks,
Hi Luis
This is my method to sum 2 fields when checkbox is checked (formula) or to write something when is not checked (not formula) using Javascript (and only javascript, no formula !)
//When document is ready $(document).ready(function() { //DO check_formula when the document is ready check_formula(); //DO check_formula when the checkbox change $('#Field4-0').change(function() { check_formula(); }); }) //Check_formula function check_formula(){ //Get Checkbox var checkBox = document.getElementById("Field4-0"); // If the checkbox is checked, execute the formula if (checkBox.checked == true){ //GET Field 1 and Field 2 var field1 = $('#q1 input').val(); var field2 = $('#q2 input').val(); //Change STRING to INT field1 = parseInt(field1); field2 = parseInt(field2); //SUM Field1 and Field2 var total = field1 + field2; //SET Field Total $('#q3 input').val(total); } else { //SET Field Total = "No formula" $('#q3 input').val("No Formula"); } }
You need to know how to get ID or Class Name for each element.
What is the reason for changing or disabling the formula?
Hi Steve,
Because Forms shows an error when submitting the form and the formula has no result.
Unfortunately LF doesn't support ERR so I'd look for a way to make it an IF calculation instead, such as
=IF(Var1="","",Your calculation)
or
=IF(AND(Var1="",VAR2=""),"",Your calculation)
The way when the fields are empty the value is "" which is a result, otherwise when the field has a value it runs the calculation.
IF the output is a number field then I would return 0 instead
=IF(Var1="",0,Your calculation)
or
=IF(AND(Var1="",VAR2=""),0,Your calculation)
You are fast Steve XD
This is mine (still using my Print Screen)
=IF(Choice.Activate_Formula,SUM(Field_1,Field_2),"Return String")
(Put this formula inside the Field Total)
Yes, that was another option that we were analyzing. The form has approximately 200 formulas, so it is difficult to add the IF to each one. Anyway, thank you both.
Have you tried just turning off Field Validation for the form?