• Resolved behruzjahangiri

    (@behruzjahangiri)


    Hello CFF!

    I’m looking to create a calculator form with pre-defined results.

    The idea is that a customer with enter their serial number and i will therefor create a ”database” of results, aligned with this one:

    if(( num > 0 ) * ( num <= 176)){ document.snf.year.value = “1859 or before”;}
    if(( num > 176 ) * ( num <= 3673)){ document.snf.year.value = “1860 – 1869”;}
    if(( num > 3673 ) * ( num <= 10933)){ document.snf.year.value = “1870 – 1879”;}
    if(( num > 10933 ) * ( num <= 22628)){ document.snf.year.value = “1880 – 1889”;}
    if(( num > 22628 ) * ( num <= 50490)){ document.snf.year.value = “1890 – 1899”;}
    if(( num > 50490 ) * ( num <= 94753)){ document.snf.year.value = “1900 – 1909”;}
    if(( num > 94753 ) * ( num <= 114822)){ document.snf.year.value = “1910 – 1919”;}
    if(( num > 114822 ) * ( num <= 136067)){ document.snf.year.value = “1920 – 1929”;}
    if(( num > 136067 ) * ( num <= 143270)){ document.snf.year.value = “1930 – 1939”;}
    if(( num > 143270 ) * ( num <= 147008)){ document.snf.year.value = “1940 – 1949”;}
    if(( num > 147008 ) * ( num <= 151342)){ document.snf.year.value = “1950 – 1959”;}
    if(( num > 151342 ) * ( num <= 161114)){ document.snf.year.value = “1960 – 1969”;}
    if(( num > 161114 ) * ( num <= 173784)){ document.snf.year.value = “1970 – 1979”;}
    if(( num > 173784 ) * ( num <= 180198)){ document.snf.year.value = “1980 – 1989”;}
    if(( num > 180198 ) * ( num <= 185272)){ document.snf.year.value = “1990 – 1998”;}
    if(( num > 185272 )){ document.snf.year.value = “Efter 1998”;}

    I’m just not sure how to exactly achvie this with your plugins, could you perhaps elaborate where in your documentation i can read more about this?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author codepeople

    (@codepeople)

    Hello @behruzjahangiri,

    I’ll assume the num variable corresponds to the fieldname1 field in the form created with our plugin, and the year field is a calculated field in the form.

    So, you simply should insert a calculated field in the form for the year, and enter as its equation (there is an attribute in the field’s settings for entering the equation), the following piece of code:

    
    (function(){
    var num = fieldname1, result = '';
    if(( num > 0 ) * ( num <= 176)){ result = "1859 or before";}
    if(( num > 176 ) * ( num <= 3673)){ result = "1860 – 1869";}
    if(( num > 3673 ) * ( num <= 10933)){ result = "1870 – 1879";}
    if(( num > 10933 ) * ( num <= 22628)){ result = "1880 – 1889";}
    if(( num > 22628 ) * ( num <= 50490)){ result = "1890 – 1899";}
    if(( num > 50490 ) * ( num <= 94753)){ result = "1900 – 1909";}
    if(( num > 94753 ) * ( num <= 114822)){ result = "1910 – 1919";}
    if(( num > 114822 ) * ( num <= 136067)){ result = "1920 – 1929";}
    if(( num > 136067 ) * ( num <= 143270)){ result = "1930 – 1939";}
    if(( num > 143270 ) * ( num <= 147008)){ result = "1940 – 1949";}
    if(( num > 147008 ) * ( num <= 151342)){ result = "1950 – 1959";}
    if(( num > 151342 ) * ( num <= 161114)){ result = "1960 – 1969";}
    if(( num > 161114 ) * ( num <= 173784)){ result = "1970 – 1979";}
    if(( num > 173784 ) * ( num <= 180198)){ result = "1980 – 1989";}
    if(( num > 180198 ) * ( num <= 185272)){ result = "1990 – 1998";}
    if(( num > 185272 )){ result = "Efter 1998";}
    return result;
    })()
    

    and that’s all.
    Best regards.

    • This reply was modified 6 years, 5 months ago by codepeople.
    Thread Starter behruzjahangiri

    (@behruzjahangiri)

    Hello @codepeople!

    Thanks for the ”translation”.

    Sadly, i can’t get it to work. Please see screenshots: https://imgur.com/a/zXwHhzk

    The link to the test page is: https://pianoservice.wpengine.com/test-side/

    Best regards, Behruz

    Plugin Author codepeople

    (@codepeople)

    Hello @behruzjahangiri,

    My apologies,my fault. Please, modify the piece of code:

    
    var n = fieldname1, result = '';
    

    as follows:

    
    var num = fieldname1, result = '';
    

    I’ve modified the code in the previous ticket too.

    Best regards.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Create a calculation form with pre-defined results’ is closed to new replies.