Hello @pexel
Thank you very much for using our plugin.
If your code is a complementary function, implemented through an “HTML Content” and not an equation, you cannot refer to the fields’ values directly by their names as you do from the equations in the calculated fields. In this case, you must use the getField operation and its val method.
Ex.
if (getField('fieldname14').val(true) == '02')Your function does not include the close key }
Best regards.
Thread Starter
pexel
(@pexel)
There should be no problem in the script right now, but it still doesn’t write results, I’ll go crazy 🙂
function calculateGCD(a, b) {
// Ensure positive values
a = Math.abs(a);
b = Math.abs(b);
// Euclidean algorithm
while (b !== 0) {
var temp = b;
b = a % b;
a = temp;
}
return a;
}
var ebob;
if (getField('fieldname14').val(true) === '02') {
ebob = calculateGCD(getField('fieldname27').value, getField('fieldname26').value);
}
if (getField('fieldname14').val(true) === '03') {
ebob = calculateGCD(getField('fieldname27').value, getField('fieldname26').value + getField('fieldname25').value);
}
// Output the result to HTML
jQuery('#calculation-ebob').html(ebob);
jQuery('.ebob-aciklama').html('En Büyük Ortak Bölen EBOB / OBEB:');
jQuery('.ebob-sonuc').html(ebob + ' TL');
// Return the value of ebob
return ebob;
- This reply was modified 3 minutes ago by pexel.
Hello @pexel
Your code has parser errors. Is the code an additional function in an “HTML Content” field, or it is an equation?
If it is an equation, it must be an auto-evaluated function: (function(){ Your code here })()
The equation cannot contain single-line comments (// ….). If you want to include comments in your code you must use block structure /* Your comment */
You are entering the function with parameters, but the parameters do not exist when you evaluate the equations.
Best regards.
