Hi,
Ok, remember you can use conditional statement in the equations:
So, suppose, your form includes two numeric fields: fieldname1 and fieldname2 for width and length respectively, and two Date fields: fieldname3 and fieldname4, for the start and end dates. Your equation would be similar to:
(function(){
var square_meter = fieldname1*fieldname2;
var period = fieldname4-fieldnam3;
var result = 0;
if(square_meter <= 45 ) result = square_meter*coeficient1;
if(45 < square_meter && square_meter <= 56 ) result = square_meter*coeficient2;
if(56 < square_meter && square_meter <= 57 ) result = square_meter*coeficient3;
//… We have a result depending of square meters
if(period<=31) result=result+square_meter*period*coeficient4;
//… Set the other intervals
return result;
})()
Note: in the previous equation you should replace the different coeficients by the real value, and complete all conditional statements required by your project.
Best regards.
hi i have 2 dynamic fields.
fieldname5 is total-meter_square
fieldname6 is total_days
i cannt did it.
please help.
Hi,
In the equation I sent you previously you only should replace:
var square_meter = fieldname1*fieldname2;
directly by
var square_meter = fieldname5;
and
var period = fieldname4-fieldnam3;
by
var period = fieldname6;
and of course, you should replace the texts: coeficient1, coeficient2,… by the real values, and insert all conditional statements required by your project.
Best regards.
i did it but something wrong i did with all conditions.
i send you the page
http://www.kaenem.com/calculated-field/
admin page:
http://www.kaenem.com/wp-admin
username: demo
password: demo
please see table with conditions.
by the way you can see all coeficient for each meter square by days.
and below calculated fields
please help
Hi,
I’m sorry, but I cannot create all your project. I’ll give you some tips to create your equation, but you should complete all conditional statements.
In your form the square meter field is the fieldname4, and the number of days is the fieldname5. So, the equation should be:
(function(){
if( fieldname4 < 56 )
{
if( fieldname5 <= 30 ) return fieldname5*1.84;
if( fieldname5 <= 60 ) return fieldname5*1.563;
if( fieldname5 <= 90 ) return fieldname5*1.327;
if( fieldname5 <= 121 ) return fieldname5*1.305;
if( fieldname5 <= 151 ) return fieldname5*0.929;
if( fieldname5 <= 181 ) return fieldname5*0.849;
// The other days of first row here
}
if( fieldname4 < 68 )
{
// The conditional statements for the second row
}
// Repeat for the other rows in your table of coeficients
})()
Best regards.
i also didnt want you to finish project but when i paste all code to “set equation” field this didnt work for me.
i sent the information website. just show me code above. i ll finish all statements.
Best regards
Hi,
The comments in the equation are only for teach you, you should not insert the comments in the equation associated to the field.
Please, check your form again, I’ve modified the equation in your website.
Best regards.