brad oyler
skipping stones Posts:8
|
05-16-2007 10:52 AM |
|
I am trying to create a basic order form, that lets the user to check checkboxes for different fees. Like Basic ($10) Advanced ($20), etc. Is there a way to have the form or email form created a total of all those values?? |
|
|
|
|
brad oyler
skipping stones Posts:8
|
02-23-2008 08:19 AM |
|
I am still trying to do this now with 2.5, but using comboboxes. Is this at all possible? I saw that some type of field calc was possible, but not sure how to use in an email event. |
|
|
|
|
Chad Nash Posts:5260
|
02-25-2008 02:23 PM |
|
Brad,
Hi. Yes you should be able to do this now with client side events. You might download the IPORTABLE file found on this Dynamic Forms Demonstration.
I also just setup a demonstration on Beta Springs to help another user wanting to calculate the field into a textbox or hidden field type so that they could then use SQL.
-Chad
|
|
|
|
|
brad oyler
skipping stones Posts:8
|
02-25-2008 07:54 PM |
|
OK, I now see the relation between client-side events, Javascript file, and the "CalculateCheckBoxListValues" function. However, what would a similar Javascript function look like for drop-down list values?
Thanks. |
|
|
|
|
brad oyler
skipping stones Posts:8
|
02-26-2008 04:54 PM |
|
My problematic form is here: http://www.w3portals.com/testform/t...fault.aspx
and now my problem is adding the two values fee1 + fee2.
Any idea what I'm doing wrong? I'm using the client side event: $(total) = $(fee1)+ $(fee2)
Thanks. |
|
|
|
|
Chad Nash Posts:5260
|
02-26-2008 07:03 PM |
|
Brad,
Hi. Great example of a useable feature, we probably need to add something into the default javascript file to calculate fields such as this.
In this example you are concatenating javascript which would be useful if they were characters (such as concatenating first and last name to be display name or something).
I did a quick search on some Javascript examples for calculating fields and saw the parseInt(field) function call. I setup a test javascript calculation field creating total demonstration form just like yours and it appears to be working.
So...
$(total) = parseInt($(fee1)) + parseInt($(fee2))
-Chad
|
|
|
|
|
Stephen Beasley
wading in the water Posts:16
|
02-29-2008 05:25 AM |
|
This might not be the right place to ask, if you would like me to start another post, I certainly wiil.
In calculating a total from check box values exactly like the sample, if the total value ends in a zero, it leaves the "0" out. For example - total is........... $35.9 - Instead of $35.90. I just thought of it, so I did not test what would happen if the cost is $35.00, but my guess is it would drop the two zeros. What would be the script for showing the zero/zeros? |
|
|
|
|
Michael Winblad
wading in the water Posts:26
|
02-29-2008 06:50 AM |
|
Thank you for letting me know about the parseInt. I should have looked at this forum entry sooner. This solved my problem but I thought I would give people a heads up. If you are adding an amount to an existing field, you want to make sure all fields have values. You can do this by defaulting the values to 0.00 when you define the form. Otherwise, you may receive an error when you perform the calculation.
As soon as I can find a java language reference on-line, I will offer something on the precision problem posed before (nice alliteration, huh). I am sure use of substring and length functions to find the position of the current decimal in the answer and then concatenate the needed number of digits and decimal depending on how close the decimal is to the end of the string. |
|
|
|
|
Stephen Beasley
wading in the water Posts:16
|
03-08-2008 10:55 AM |
|
Hi,
I have found a very easy solution (I can get it to work in a simple HTML) but I do not know how to implement in custom javascript:
The code that works is:
var field = 35.90;
var total = '$' + field.toFixed(2);
or without calling variables
total = '$' + total.toFixed(2);
So can you create a function in custom javascript to just say $(the inputvalue) = $(the inputvalue).toFixed(2); Obviously this does not work, but I can't figue out what the "name" of the input field of the question is?? Or just a script to say whatever the end result or value of the textbox input, convert it to xxxxxxx.toFixed(2); Anybody have any ideas to try?? I like the calculatecheckbox and the way it works, but when yo have 99 options, well, it doesn't look good. I can't even believe when they were creating JS nobody ever thought of currency, like currency($(shortname). There is sine, cosine, theories i've never heard of etc...But nothing for currency??? |
|
|
|
|
Anthony Sutton Posts:14
|
05-05-2008 10:55 PM |
|
Posted By Chad on 02/26/2008 9:03 PM
Brad,
Hi. Great example of a useable feature, we probably need to add something into the default javascript file to calculate fields such as this.
In this example you are concatenating javascript which would be useful if they were characters (such as concatenating first and last name to be display name or something).
I did a quick search on some Javascript examples for calculating fields and saw the parseInt(field) function call. I setup a test javascript calculation field creating total demonstration form just like yours and it appears to be working.
So...
$(total) = parseInt($(fee1)) + parseInt($(fee2))
-Chad
Chad, I am getting a Error on this form "total is undefined", I have you form exactly and it is on your beta site I get that error. It must be some thing on my server , any suggestion on how i could go about fixing this?? Thx
|
|
|
|
|
Chad Nash Posts:5260
|
05-06-2008 07:34 AM |
|
You might set the form up exactly as you have it on your server but on beta springs (from scratch). From there we can determine what the difference is between your form and the form with the link above. There shouldn't be anything specifically different on your server for this. Also, keep in mind that '$(total)' is actually the short field name for the 3rd field. What is the short field name for your 3rd field set to? |
|
|
|
|
Anthony Sutton Posts:14
|
05-06-2008 08:21 AM |
|
Chad thanks for the response, I spent a few hours on this yesterday, and after no success getting it to work I exported the content from beta springs because I knew that worked. I imported it to my site and wham, same error. so building from scratch on beta springs will work but will not solve my issue. I can setup an admin account for you on my site so you can see what I am talking about. Thx. |
|
|
|
|
Chad Nash Posts:5260
|
05-06-2008 10:46 AM |
|
Hi. Yes, please do (please email us or open support ticket to give this info). Then we can follow up with this post in case other users run into this. As far as I know the only requirement after export/import is to go into the module configuration and save the javascript file at least one time. This is because there is a setting that displays if it has already saved the javascript file the first time you go into the module configuration, well when you export/import all of the settings this tells the module that you already have so it doesn't do this for you. That should be the only requirement though so please open a support ticket and we can follow up here when we find out what was causing the problem on your end. |
|
|
|
|
Chad Nash Posts:5260
|
05-07-2008 09:09 AM |
|
Hi guys... I wanted to follow up on this thread as we reviewed this yesterday. It appears (for performance reasons) that it only parses tokens for short field names within client side events... if those tokens have a client side event attached to it. We will review this in the future but basically what was happening here is that the client side javascript was using $(total) within it, however the total field wasn't using any client side event. So we added the same function call (to total two fields) into the client side event for the total field and this fixed it up. Another note: If you are signed in as the admin, adding ?Debug=True to the querystring will spit out the exact client side event that is being rendered. This allows you to see if there are anything within the event that doesn't look right. Thanks, Chad |
|
|
|
|
Heather
wading in the water Posts:23
|
10-10-2008 08:58 AM |
|
Just a follow up note. I noticed in the javascript for 2.7 that you had added the formatCurrency tag to solve the "decimal" issue. Works great! Thanks. |
|
|
|
|
Chad Nash Posts:5260
|
10-10-2008 09:01 AM |
|
Yes.. Also, we will continue to add to the 'default JavaScript file' but also keep in mind even in running earlier versions of Dynamic Forms that you can always add, create, or save the JavaScript. So if the JavaScript you are wanting to use is on Beta Springs and not yours you can always copy/paste and click 'Save JavaScript File' on your module instance. -Chad |
|
|
|
|
Andres Odio
new to the springs Posts:3
|
12-28-2008 08:20 PM |
|
Hi, I tried importing the .xml file from Demonstration 6 ( http://www.datasprings.com/Products...ult.aspx), such that my module looks exactly the same. However, when I click on one of the Products checkboxes, the Total does not get updated and I get a Java error. The error that appears is: "Object expected". Does anyone know what could be wrong? Thanks |
|
|
|
|
Candace
river guide Posts:2431
|
12-29-2008 08:08 AM |
|
Hi Andres, Chad's comments above on 10/10/08 might help you. Have you tried this yet under Module Configuration? Candace |
|
|
|
|
Kellyo
river guide Posts:113
|
05-05-2010 03:47 PM |
|
I have a total that is calculated from combo boxes .. it worked perfectly .. then I exported the module as template and imported it into a new page ( a second form , and now formatCurrency no longer works. It still works fine on the original form .. but on the copied form it does not .. same code. The total updates correctly in a hidden "Total Field" and if I remove the formatCurrency() from the displayed total HTML field it does works .. but when I add formatCurrency() back in I get an object expected error. ??
I've tried renaming fields and innerHTML id etc .. but no luck.
Kelly |
|
|
|
|
Kellyo
river guide Posts:113
|
05-05-2010 03:58 PM |
|
Hi Chad/Candace, regarding previous post .. I copied the javascript file from the module config in the first page form .. and pasted it into the second page form. This resolved the issue.
So just a note that perhaps .. something in the formatCurrency js gets messed up on export/import. Version 3.3.4 on DNN 5.4.1
Kelly |
|
|
|
|
David To
river guide Posts:2719
|
05-06-2010 06:54 AM |
|
HI Kelly, the Javascript file doesn't get retained on export / import of XML so any functions that get modified or added in one form will not retain on export / import into another form under the Javascript File ar ea. -- David |
|
|
|
|