Not signed in (Sign In)

Vanilla 1.1.5a is a product of Lussumo. More Information: Documentation, Community Support.

    • CommentAuthorcleanplus
    • CommentTimeMar 31st 2011
     
    Hi all

    I'm not very up on excel, so I will try to explain what I'm trying to do.

    I'm setting up an online quote form for prospective clients.
    They enter how many hours they want to have our service, then the form will calculate whet the charge will be.
    But my problem is I want to charge rates dependent on the number of hours.

    for example:

    Hours Rate

    1-14 9.50
    15-24 9.00
    25+ 8.66

    how can I program this in my forms so it calculates automatically?

    I hope someone can help
    • CommentAuthorjlabau
    • CommentTimeMar 31st 2011
     
    This is actually really tricky to do as far as we can tell. Our organization had a similar use case, and we tried to attack it with 'else if' statements in the form calculation fields. However, it seems that FA concatenates the code to eliminate spaces, so we handled it with a switch/case solution instead. I would love to know if there is a way to embed 'else if' syntax in here somehow.

    (I realize that was a more technical answer than you were probably looking for - my hope is that FA will respond with a solution based on our mutual experience).
    • CommentAuthorcleanplus
    • CommentTimeMar 31st 2011
     
    whats a switch/case solution please
    • CommentAuthorjlabau
    • CommentTimeMar 31st 2011
     
    It's a little bit cumbersome, but it would work for you. Basically, you write a (very long) bit of Javascript that would go in a form calculation. For example, here's one that calculates the price of an item based on the quantity:

    switch(qty){case(1):(34.99);break;case(2):(32.99);break;case(3):(32.99);break;case(4):(32.99);break;case(5):(32.99);break;default:(29.99);break;}

    In this example, the variable (qty) is tested against different values for qty - (1), (2), (3), etc. all the way up to (5). Each number after the colon represents the price in dollars for that particular case. So, when the qty variable equals 3, the price equals 32.99. Anything above this is handled with the default, which is 29.99.

    In your instance, you would need to write a statement that contains a case for every possible qty up to 25, after which you would specify a default.

    In other programming languages you can use comparison operators in your cases to create ranges, but I haven't found a Javascript hack to do this.
    • CommentAuthorcleanplus
    • CommentTimeApr 1st 2011
     
    Thanks very much, I will give it a try
    • CommentAuthorcleanplus
    • CommentTimeApr 2nd 2011
     
    hi jlabau

    I hope i'm not been a pain, but could you help me a bit more, I'm not very savy with this java language.

    Please would you be able to start me off with say up to three, this way I should be able to carry on from there.
    at those hours we charge 9.80 per hour.

    Here's hoping

    drew
    admin@cleanplus.org.uk
    • CommentAuthorjlabau
    • CommentTimeApr 2nd 2011
     
    Drew,

    Sure thing! In your scenario, you would simply substitute your variable for 'hours" in the following:

    switch(hours){case(1):(9.8);break;case(2):(9.8);break;case(3):(9.8);break;case(4):(9.8);break;case(5):(9.8);break;default:(9.8);break;}

    When you get up to 15 they would start to look like this:

    case(15):(9.00);break;case(6):(9.00);break; etc.

    Josh
    • CommentAuthorcleanplus
    • CommentTimeApr 3rd 2011
     
    Thanks very much Josh
    • CommentAuthorcleanplus
    • CommentTimeApr 3rd 2011
     
    where do i put the script in the formassembly system?
    • CommentAuthorcleanplus
    • CommentTimeApr 4th 2011
     
    fANTASTIC...SORTED IT
    THANKS
    • CommentAuthordbuschho
    • CommentTimeApr 5th 2011
     
    Hello guys,

    I think we also covered this in a support request with Drew, but another solution from what Josh had might be:

    if(HOURS<14){HOURS*9.50}if(HOURS>14&&HOURS<24){HOURS*9.00}if(HOURS>24){HOURS*8.66}

    did the above work for you, Drew?

    FormAssembly.com Support
    • CommentAuthorjlabau
    • CommentTimeApr 6th 2011
     
    Ah-ha! I didn't realize you could do successive if statements like that. Will give it a try in our own system.

    Thanks!