Saturday, February 11, 2012
  Search
Support Forum
Calculations within a Form
Last Post 25 Mar 2008 12:05 AM by Sujay. 26 Replies.
AddThis - Bookmarking and Sharing Button Printer Friendly
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Page 1 of 212 > >>
Author Messages
Anne
New Member
New Member
Send Private Message
Posts:36


--
04 Oct 2007 03:07 PM  
I have a requirement to perform calculations based on the values that a visitor enters on a form. Does form master have that functionality?


Sujay
Basic Member
Basic Member
Send Private Message
Posts:382


--
04 Oct 2007 03:20 PM  
Hi Anne,

Form Master does not support that functionality.
I can help you with some javascript techniques if those calculations are quite simple.
Please let me know what type of calculations you require.

Thanks & Regards,
Sujay



Anne
New Member
New Member
Send Private Message
Posts:36


--
04 Oct 2007 03:48 PM  
Hi - the calculations are simple. The form will be divided into sections where the visitor enters amounts. Each section is summed to give a Sub Total. The individual sub-totals are added together to give a total. The most complicated calculation takes the one value and does a multiplication and subtraction e.g. (SubtotalA*12*20)-SubtotalB.


Sujay
Basic Member
Basic Member
Send Private Message
Posts:382


--
04 Oct 2007 03:57 PM  
Hi Anne,

I will provide you with a small sample shortly, you can implement it similarly.

One more thing this is beyond the scope of Form Master and is provided without any warranty (though it won't introduce any side effects). So by using this you agree that you are doing it at your own risk.

Thanks & Regards,
Sujay


Anne
New Member
New Member
Send Private Message
Posts:36


--
04 Oct 2007 04:05 PM  
Hi Sujay
Thanks very much. I really appreciate your help, and yes I understand that I will be using the code at my own risk.

Regards,
Anne


Sujay
Basic Member
Basic Member
Send Private Message
Posts:382


--
04 Oct 2007 04:16 PM  
Hi Anne,

I will provide you a sample asap.

Thanks & Regards,
Sujay


Sujay
Basic Member
Basic Member
Send Private Message
Posts:382


--
04 Oct 2007 08:28 PM  
Hi,

I am attaching the sample form with 3 textboxes for SubTotalA ,SubTotalB and Result.


Here is the procedure i used
I am using the css class of each of the input boxes to identify them at browser level (so you need to give Unique css for each of the textboxes, This seems ugly but no other simple way is there to this) ,
So for the three textboxes i gave css classes like SubTotalA,SubTotalB,Result.

At the end of the Page i added a dummy label (to induce javascript into the page) ,
I have added all my javascript to the label text (It will not be visible in the html page as it start with script tag).

If you edit the javascript make sure that there will be no new line characters in the script.

I used the following script to calculate, The only line you might be interested is var result=(subtotala*12*20)-subtotalb;

[script removed]

Attachment: 110428113571.zip

Sujay
Basic Member
Basic Member
Send Private Message
Posts:382


--
04 Oct 2007 08:32 PM  
Hi,

Few characters in the script are been removed, so i am attaching script as attachment.

Thanks & Regards,
Sujay

Attachment: 1104321153054.zip

Anne
New Member
New Member
Send Private Message
Posts:36


--
16 Oct 2007 03:53 PM  
Hi - I have uploaded you sample form and it works perfectly. However, if I try and add the script to my own form it does nothing. I have copied the script you sent me into the Label Text in the text box; I have copied into the HTML view of the Label Text. Nothing works. If I go into the dummy label of the form I imported, you cannot see any of the java script so I can't see what I am doing wrong. Any ideas?


Sujay
Basic Member
Basic Member
Send Private Message
Posts:382


--
17 Oct 2007 12:45 AM  
Hi Anne,

Please export you form and post it here.

Thanks & Regards,
Sujay


Anne
New Member
New Member
Send Private Message
Posts:36


--
17 Oct 2007 09:57 AM  

If I load the script onto the label text - then my xml looks like FNACalculator2.xml (all wrong, as you'll see).
If I load the script on the HTML view of the label text, then the xml looks like FNACalculator.xml (script is missing).

The script that I copied and pasted is in the CalcAssets.txt.


Attachment: 11017575060671.zip

Sujay
Basic Member
Basic Member
Send Private Message
Posts:382


--
17 Oct 2007 11:01 AM  
Hi Anne ,

You did everything right, you can load script into label text,

The only thing you should take care is the script should not have any new line characters, open your script in notepad remove all the new line characters and make the script appear in a single line.
I am attaching the modified FNACalculator2 as FNACalculator3.

If you need to change the script, change it in notepad then remove all the new line characters,
 and while updating remove the previous text in Default textbox and add the new script in label text.

Also add 0 for all textboxes by default.
Hope this helps.


Thanks & Regards,
Sujay

Attachment: 1101711171471.zip

Anne
New Member
New Member
Send Private Message
Posts:36


--
17 Oct 2007 11:10 AM  

Thanks Sujay!



Anne
New Member
New Member
Send Private Message
Posts:36


--
30 Oct 2007 03:22 PM  
Thanks for all your help. Finally got it working. Final version is at financial needs analysis calculator.
Wanted to send the results via email, but the calculations are then lost, so I am going to take that out.


Sujay
Basic Member
Basic Member
Send Private Message
Posts:382


--
30 Oct 2007 06:12 PM  
Hi,

cool, good work

Thanks & Regards,
Sujay


cunnke
New Member
New Member
Send Private Message
Posts:3


--
07 Feb 2008 10:08 PM  

I need to do subtotal calculations on a form also.

We keep track of commodities that a client have on-site. We are wanting to keep a running total at the bottom of the form. When the client submits the information it sends the information including the running total at the bottom of the screen to our customer service reps by e-mail.

There's 20 items that we need to subtotaled



Sujay
Basic Member
Basic Member
Send Private Message
Posts:382


--
07 Feb 2008 11:17 PM  
Hi,

Currently attachments previously attached are not been displayed due to some technical problems, it will be resolved within a day and you can see the samples attached, i will try to find out if i have a backup of those files.


Thanks & Regards,
Sujay


Anne
New Member
New Member
Send Private Message
Posts:36


--
08 Feb 2008 05:45 AM  
With the form I developed, when the client submits the information the calculations are lost. Is this the problem that you are going to be correcting?


Sujay
Basic Member
Basic Member
Send Private Message
Posts:382


--
08 Feb 2008 09:07 AM  
Hi Anne,

I posted it for Kyle,
but i would like to resolve that issue, please export your form and mail it to c5.cust.service at code5systems.com

Thanks & Regards,
Sujay


Sujay
Basic Member
Basic Member
Send Private Message
Posts:382


--
08 Feb 2008 02:26 PM  
Hi Anne,

I found the problem with your form, you should uncheck the disable user input checkbox,
but then user will be able to input value there so to avoid that you need do these steps.

1)note all the textboxes for which input should be disabled, like txt12 etc
add this code at the end for all the textboxes
txt12.disabled=true;
so on for all textboxes

2)Now register the onbeforeunload event with this code
document.body.onbeforeunload=BeforeUnload;

3)Now before the form is posted enable the textboxes again before submit
function BeforeUnload(){txt12.disabled=false;}
so on for all textboxes

Thanks & Regards,
Sujay


You are not authorized to post a reply.
Page 1 of 212 > >>


Active Forums 4.2
Copyright 2004-2012 Code 5 Systems, LLC.