Totally do-able in Freeway. As long as you promise not to trust the amount (don’t blindly accept whatever the value calculated on screen comes to – always do this calculation over again on the server or in your back office) then you can build something like this very easily.
The CalendarView Action will give you the calendar pickers. Call these date1 and date2 in the Name field of the Inspector (on the third tab).
For each of your pickers, you need to follow this recipe:
- The Name of the picker should be a valid variable name, like hmi_2_5 (a variable name MUST begin with a letter, and MUST not contain any punctuation other than an underscore, or any spaces). It should be unique on the page. (If it is duplicated, then the last one will “win”, overwriting any previous same-name fields.)
- For each option, the Value should be set to the price and the Choice should be set to the quantity. So if 1 costs £35 and two costs £65 (discount for quantity) then you would set the price accordingly. Don’t use any currency prefix in the price, though, just use the integer price. If you are using cents, like $1.49, then enter all prices in cents (seriously, it makes the math so much easier later on). Just enter 149 without the decimal.
- I’m not going to get into the bit about the Best Boy and Gaffer and that – it’s out of scope of what I can show you quickly here.
- Draw an HTML box on the page where you want the results to show, and enter a bit of placeholder text in it like Total Amount: £0. Make sure you style this text with a paragraph style, don’t use the Inspector or any non-paragraph style, or the result will look like 16px Times Roman.
Now for the magic (in the DOM Loaded Observer editor in Protaculous 2:
var output = $('theIDofYourHTMLBox').down('p');
var form = $$('form').first();
new Form.Observer(form, 0.3, function(evt, value){
var total = 0
var d1 = $F('date1').split('-');
var d2 = $F('date2').split('-');
d1 = new Date(d1[0],d1[1],d1[2]);
d2 = new Date(d2[0],d2[1],d2[2]);
var days = Math.abs(Math.round((d2.getTime() - d1.getTime()) / 86400000)) || 1;
$$('select').pluck('value').collect(function(opt){
total += parseInt(opt * days, 10);
});
output.update('Total Amount: £' + total);
});
IF you’ve followed the rules here, you should end up with a completely working solution. If the dates aren’t filled in, then the total will be for 1 day.
Walter
On Apr 16, 2013, at 11:24 AM, Phil Moreton wrote:
Hi all,
I’ve been trying to create a quotation form for my website. I’ve used formsite.com before but it is not perfect.
I then came my friends website that has a very simple looking page, but deep down it looks like it has some complex elements involved.
Is there anyway in creating something like this in Freeway pro?
If you look at the website: http://www.susulights.com:
- it gives the user a date calendar, depending on how days you select it then multiplies the amount.
Any ideas if this is possible?
Best,
Phil
http://www.susulights.com
freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options
freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options