Hello @klingbeil
The code snippet below returns the variables’ values concatenated with comma symbols. But as you define the variables into conditionals, some of them are empties:
return [bedelliterhistarihi, kisadonemterhistarihi, uzundonemterhistarihi];
The correct would be to include separated return instructions.
(function () {
var bedelliterhistarihi,
kisadonemterhistarihi,
uzundonemterhistarihi;
if (fieldname14 == 'A') {
bedelliterhistarihi = CDATE((fieldname23 + 5), 'dd/mm/yyyy');
jQuery('#calculation-bedelliterhistarihi').html(bedelliterhistarihi);
jQuery('.askerlikterhistarihi-tanim').html('Resmi Terhis Tarihi :');
jQuery('.askerlikterhistarihi-sonuc').html(bedelliterhistarihi);
return bedelliterhistarihi;
}
if (fieldname14 == 'B') {
kisadonemterhistarihi = CDATE((fieldname23 + 5), 'dd/mm/yyyy');
jQuery('#calculation-kisadonemterhistarihi').html(kisadonemterhistarihi);
jQuery('.askerlikterhistarihi-tanim').html('Resmi Terhis Tarihi :');
jQuery('.askerlikterhistarihi-sonuc').html(kisadonemterhistarihi);
return kisadonemterhistarihi;
}
if (fieldname14 == 'C') {
uzundonemterhistarihi = CDATE((fieldname23 + 5), 'dd/mm/yyyy');
jQuery('#calculation-uzundonemterhistarihi').html(uzundonemterhistarihi);
jQuery('.askerlikterhistarihi-tanim').html('Resmi Terhis Tarihi :');
jQuery('.askerlikterhistarihi-sonuc').html(uzundonemterhistarihi);
return uzundonemterhistarihi;
}
return '';
})();
Best regards.
Hello,
I did as you said and added the number to be collected at the end, this time it didn’t add it on the date, it just wrote it next to it.
01/11/20235
01/11/2023(5)
if (fieldname14 == 'A') {
bedelliterhistarihi = CDATE((fieldname23 + 5), 'dd/mm/yyyy');
jQuery('#calculation-bedelliterhistarihi').html(bedelliterhistarihi);
jQuery('.askerlikterhistarihi-tanim').html('Resmi Terhis Tarihi :');
jQuery('.askerlikterhistarihi-sonuc').html(bedelliterhistarihi);
return bedelliterhistarihi;
}
Hello @klingbeil
Which is the control type of the fieldname23 field? If it is not a date field, but a text with date format (dd/mm/yyyy), the correct would be to use the DATETIMESUM and GETDATETIMESTRING operations:
bedelliterhistarihi = GETDATETIMESTRING(DATETIMESUM(fieldname23, 'dd/mm/yyyy', 5, 'd'), 'dd/mm/yyyy');
Best regards.
Hello. I am adding and subtracting time by entering the year month day week value on the date. There is no problem with the calculation process. But I am trying to print the numbers entered by the user on the time:result screen. For example: If the user entered 1 Year 4 Weeks Duration : Side by side 1 Year 4 Weeks will be written in this field. If he fills and empties one of these fields while calculating again, it will write the current value again. How to do this, I’ve been struggling since morning.
Link:
var result = '';
var eklenensure = '';
if (fieldname19) {
eklenensure = fieldname19;
result += eklenensure + ' Yıl';
}
if (fieldname20) {
eklenensure = fieldname20;
if (result !== '') {
result += ' ';
}
result += eklenensure + ' Ay';
}
if (fieldname21) {
eklenensure = fieldname21;
if (result !== '') {
result += ' ';
}
result += eklenensure + ' Hafta';
}
if (fieldname22) {
eklenensure = fieldname22;
if (result !== '') {
result += ' ';
}
result += eklenensure + ' Gün';
}
// Güncel değerleri hesaplamak için sıfırlama yap
jQuery('#fieldname19').val('');
jQuery('#fieldname20').val('');
jQuery('#fieldname21').val('');
jQuery('#fieldname22').val('');
if (result.trim() === '') {
jQuery('#calculation-eklenensure').empty().hide();
} else {
jQuery('#calculation-eklenensure').html(result).show();
}
return eklenensure;
Hello @klingbeil
The plugin replaces the fields’ names with their corresponding values before evaluating the equations to use them in mathematical operations. To refer to the fields’ names directly, you must use the |n modifier (Ex. fieldname19|n). Additionally, if you want to assign a value to a field, it is preferred to use the plugin operations. And finally, since the plugin minifies the equations’ code, you should not use comments with single-line structure (//…). Please, enter comments in block format instead (/* … */)
The equation would be:
(function(){
var result = [],
eklenensure = '';
if (fieldname19) {
eklenensure = fieldname19;
result.push(eklenensure + ' Yıl');
}
if (fieldname20) {
eklenensure = fieldname20;
result.push(eklenensure + ' Ay');
}
if (fieldname21) {
eklenensure = fieldname21;
result.push(eklenensure + ' Hafta');
}
if (fieldname22) {
eklenensure = fieldname22;
result.push(eklenensure + ' Gün');
}
/* Güncel değerleri hesaplamak için sıfırlama yap */
getField(fieldname19|n).setVal('', true);
getField(fieldname20|n).setVal('', true);
getField(fieldname21|n).setVal('', true);
getField(fieldname22|n).setVal('', true);
jQuery('#calculation-eklenensure').html(result.join(' '))[IF(result.length, 'show', 'hide')]();
return eklenensure;
})()
Best regards.
Hello,
I print the result as a date as much as the value entered on the code at the bottom.
For example, the user chose the date : 21/05/2023 and wrote 5 days on it.
Date : fieldname17
Value : fieldname27
My question is; I am now printing the date as much as the entered value, but how do I print 12 times forward in the same way?
Example :
1st value 21/05/2023
2nd value 26/05/2023
3rd value 31/05/2023
I want to calculate the result of 12 values as the value written in the form forward.
Thanks.
(function(){
var adetsure = GETDATETIMESTRING(DATETIMESUM(fieldname17, 'dd/mm/yyyy', fieldname27, 'd'), 'dd/mm/yyyy');
jQuery('#calculation-adetsure').html(adetsure);
return adetsure;
})()
Hello @klingbeil
You can implement the equation as follows:
(function () {
var adetsure = [];
for(let i = 1; i <= 12; i++){
adetsure.push( GETDATETIMESTRING(DATETIMESUM(fieldname17, 'dd/mm/yyyy', fieldname27*i, 'd'), 'dd/mm/yyyy') );
}
adetsure = adetsure.join('<br>');
jQuery('#calculation-adetsure').html(adetsure);
return adetsure;
})()
Best regards.
I’m having a bit of a hard time switching to the new method, but it’s my last form page.
fieldname38 : Today Date
d: Selected Date
I am trying to find the number of days by subtracting it from the date, where is the error, I am getting blank results.
(function(){
var d = CONCATENATE(fieldname33,'/', fieldname34, '/', fieldname35);
var toplamgunfarki= ABS(fieldname38 - d);
jQuery('#calculation-toplamgunfarki').html(toplamgunfarki + ' Gün');
return toplamgunfarki;
})();
Hello @klingbeil
You can use directly ABS(fieldname38 – d); only if both operands are date fields or numbers. But in your equation, the “d” operand contains a text with date format. In this case, you must use the DATEDIFF operation:
var toplamgunfarki= DATEDIFF(fieldname38, d, 'dd/mm/yyyy', 'd')['days'];
Please, read the date/time operations module by visiting the following link:
https://cff.dwbooster.com/documentation#datetime-module
Best regards.
Thank you very much for your support. You patiently answer all of our questions.