Great Ideas. Always Flowing.

We are not happy until you are happy. Client satisfaction guaranteed. Whatever your needs and requirements, we have the skills and resources for the job!

Quick login...


Or... now make it easy with Facebook Integration
Connect via Facebook



Top Sellers

Frustrated over the lack of customization for your user's registration fields? Dynamically setup your DNN Portal with custom registration fields, layout, questions, and other core integration options......

Ultra Video Gallery is a brother product of Ultra Media Gallery, UVG allows you to upload videos in various format and automatically encode them to flv or H264 format, you also can add videos from internet or record live videos from your webcam.

Build high performance, completely customizable data-entry forms and views driven by your DNN and external databases. New built-in tools make it a snap to quickly create data entry forms, data views, and even database tables. Plus, add your own HTML, CSS, Javascript, SQL commands, stored procedures,

The most advanced DotNetNuke shopping cart on the planet. Easy to use e-Commerce, Secure Shopping Cart Software and SEO friendly. B2C / B2B Ecommerce Sites.

One stop solution for events calendar and events registration! FREE DOWNLOAD is available now!

calculate fields
Last Post 10-08-2008 05:04 PM by Chad Nash. 9 Replies.
AddThis - Bookmarking and Sharing Button Printer Friendly
  •  
  •  
  •  
  •  
  •  
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
Piet JansenUser is Offline
skipping stones
skipping stones
Posts:12
Avatar

--
09-18-2008 07:29 AM

    I've just purchased the module because I read that it was possible to calculate fields. Now I find that you have to program javascript in order to do this. I have no knowledge of Javascript so this is a problem for me.

    What I want to do is sell tickets. There are 2 textfields: "tickets for under 14 (5 dollar a piece)" and "tickets for 15 and older (10 dollar a piece)". Now I want a total field that will display the total amount. So if a user types 3 in textfield 1 and 5 in textfield 2, the total field should show 65 dollar.

    I also want this total to show in the form results (when downloading as excel sheet).

    I hope someone can explain this to me, because viewing the source of the examples on betasprings.com is hard for me to understand.

    If no one can help me with this, and knowledge of javascript is mandatory for using this module, then I'm afraid I've made the wrong decision in purchasing this module.

    Thanks in advance.

    Chad NashUser is Offline
    Posts:5260
    Avatar

    --
    09-18-2008 01:44 PM

    Piet,

    Hi. Well first, there is no JavaScript knowledge required for any basic calculation. There are tokens you need to use which that are Dynamic Forms specific which the module will render the javascript for you, but you don't have to actually know javascript to handle these. For example, if you had a field called Price 1 with a short field name of Price1, another for Price 2 with a short field name of Price2 and then a 3rd field called Total with a short field name of MyTotal you could easily create a client side validation such as this:


    $(MyTotal) = $(Price1) + $(Price2)


    You could put that same client side validation in both of the price client side events sections. This way whenever a user changed either price 1 or price 2 it would update the total field.


    Assuming that the Total field was either a textbox or a hidden variable, this would be a seperate form field and therefore would end up being exported when you exported the results to Excel.

    So... again, any $(Tocken) such as this is not actually javascript, its Dynamic Forms functionality to reference that field or fields value.

    Javascript is usually only required when you need or would like to add additional logic to your scenario or the calculation involves complex field types such as if you wanted to calculate based on a coupon code the user entered or maybe calculate based on radio buttons etc... For these cases we do try and provide as many tutorials and/or forms you can download to start from, and we also provide you with many references for these types of calculations on Beta Springs.

    For this example, it sounds to me like you would start with setting up a 'total' field so that you know the total is coming up properly. If you wanted to you could then change it to show the total in HTML or you could change it be a hidden field. Then I would start with a basic client side event to make sure its working so when you change Textfield1 it will update the total. You could do...

    $(MyTotal) = 5 + 5


    Based on your description I think your end total would be something like:

    $(MyTotal) = ($(TextField1) * 10.00) + ($(Textfield2) * 15.00)


    If you still run into problems or can't figure it out please setup a test page on Beta Springs and let us know what it is. We will review it and see if we can provide some assistance there.


    Thanks!

    -Chad

    Piet JansenUser is Offline
    skipping stones
    skipping stones
    Posts:12
    Avatar

    --
    09-18-2008 10:52 PM

    Great! I see that I was too hasty with my conclusions. That's what having a deadline does to you

    Thanks a lot, it works great!

    Piet JansenUser is Offline
    skipping stones
    skipping stones
    Posts:12
    Avatar

    --
    09-19-2008 12:26 AM
    Another (small) issue: The calculation works fine when filling in the form itself and the "MyTotal"-textfield indeed shows up in the form results and in the email. However, in the results and in the sent email the value is not the calculated value, but 0 (or whatever default value is specified for "MyTotal").
    Chad NashUser is Offline
    Posts:5260
    Avatar

    --
    09-19-2008 10:38 AM

    Hi. Glad to hear!

    This depends on what you are updating... This is because when you are displaying it to the user you are probably showing it in HTML or showing it in a read-only field (which viewstate will not save for readonly fields). I imagine if you used a standard textbox field and not read only it would show up properly.

    So... The work around is to use two fields and update the calculation there. For example set the total for the read only textbox or html area, and then also under it set the total for a hidden field variable. Then reference the hidden field variable within the email event.

    So.
    $(MyTotalReadOnlyField) = 5 + 5;
    $(MyTotalHiddenField) = 5 + 5;

    Then reference the hidden field as the read only field will render 0.



    -Chad

    Piet JansenUser is Offline
    skipping stones
    skipping stones
    Posts:12
    Avatar

    --
    09-19-2008 11:38 PM
    Ok, thanks, that works. Though not quite as expected.

    Hiding the "MyTotalHiddenField" from all users except administrators still causes it to not show up in the email. What I did was hide the label and hide the textfield by changing it's css visibility property to hidden. That way it does show up in the email.
    (also, checking the "hide from users"-checkboxes doesn't save correctly. It does save it, but they are unchecked again when going back into the textfield settings.)

    Another thing that doesn't work quite right, is the excel results. I've set the "MyTotalReadOnlyField" to "Do not display field results within the view results module" and "Do not save field results to the database", and these are unchecked for the "MyTotalHiddenField". Still, both are listed in the excel sheet, and the "MyTotalReadOnlyField" has the correct values listed under it, where "MyTotalHiddenField" has no data listed under it. This should be the other way around. "MyTotalReadOnlyField" shouldn't be in the excel sheet at all actually.

    But at least I can see the correctly calculated amounts in the excel sheet and the email does work as intended.
    HeatherUser is Offline
    wading in the water
    wading in the water
    Posts:23
    Avatar

    --
    10-07-2008 03:11 PM
    Here's a another DF language question. I'm trying to send the total to my "Total" Text/HTML question and to another hidden field. It's working great for the hidden field-HTotal but I can't get the HTML to function. Here's one of the many configs I've tried! (:

    $(HTotal) = $(Quantity) * 37.50;Total.innerHTML = 'Total with shipping: ' + '$' + $(Quantity) * 37.50 + ''

    I pulled the language from betasprings, but I'm missing something! Thanks for your help. Heather
    Chad NashUser is Offline
    Posts:5260
    Avatar

    --
    10-07-2008 07:34 PM
    Is the example working on Beta Springs? If so what page? I would enable debug mode on the form and this should spit out the specific javascript that the form is rendering and should help us in debugging it.

    Does it work independently if you just did the $(HTotal) field or if you just did the total DIV?

    -Chad
    HeatherUser is Offline
    wading in the water
    wading in the water
    Posts:23
    Avatar

    --
    10-08-2008 08:22 AM

    Here's the betasprings page I used as an example.  The only difference is that I'm not using a checkbox calculation just a simple qty.

    http://www.betasprings.com/Dynamic-...fault.aspx

    I set mine up on betasprings as well, so you can see the difference.  I'm sure it has to do with the client side event language on the field   # of prints (my quantity field), but I can't seem to get it right. 

    http://www.betasprings.com/Dynamic-...fault.aspx

    Total calculation is working great, but not the Text/HTML.  Thanks again!! H

    Chad NashUser is Offline
    Posts:5260
    Avatar

    --
    10-08-2008 05:04 PM
    Heather... Please check the page again.

    A few things.

    1. I don't think it was causing an issue, however the fact that you have 'Quantity' as the short field name for both the textbox and the HTML area is never a good idea. Just a cool rule to live by but I don't think it was making a difference in this area.

    2. In the demonstrations/examples of setting the HTML, if you choose 'Basic Textbox' you will see that the html is actually a DIV tag with an ID='Total' etc... This is why you reference it as 'Total.InnerHTML' etc... IF you named the DIV tag 'MyTotal' then you would reference it was 'MyTotal.InnerHTML' etc... So, when I checked this field and chose basic textbox I noticed that it was using a paragraph tag and not a div tag, I changed this to DIV, set the ID to be called 'Total' and it started working. You don't have to use a DIV tag for this (you could use SPAN or a few other options) but anyway this is what you need to do and what we are doing in the other examples/demonstrations for manually setting and changing HTML fields using client side events.


    -Chad

    You are not authorized to post a reply.


     
     

    Join our mailing list...

    Get current news and events the easy way
    Subscribe Me

    Recent Blogs...

     
    Copyright 2005 - 2011 by Data Springs, Inc.
     
  • film izle
  • 720 izle
  • film
  • sinema izle
  • film makinesi
  • T�rk�e dublaj film
  • film izle
  • film izle
  • baglan film izle
  • sinema izle
  • 1080 film izle
  • film mercegi