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!

Run Javascript on submit
Last Post 09-06-2013 06:32 AM by Ryan Bakerink. 7 Replies.
AddThis - Bookmarking and Sharing Button Printer Friendly
  •  
  •  
  •  
  •  
  •  
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
RobUser is Offline
skipping stones
skipping stones
Posts:8
Avatar

--
09-05-2013 12:08 PM
    Hello,

    I am trying to find a place in Dynamic Forms where I can set up a Javascript function that will run when the submit button is clicked. I cannot use the "save/submit javascript" because the Javascript entered in this box does not seem to allow token syntax to be used such as $(FirstName).

    Essentially what I have is a situation where a series of calculations need to be made on submit, that get their values from fields on the form and then populate hidden fields. So what I want is a series of calculations such as this:

    $(Total1) = parseInt($(Q1)) + parseInt($(Q13));
    $(Total2) = parseInt($(Q8)) + parseInt($(Q11));

    ...and so on. Total1 and Total2 are hidden fields and Q1, Q13 etc are visible fields on the form.

    I cannot place these calculations in each field's client events because a) there are 80 such fields, and 2) the calculations depend on other fields which may not be input yet.

    I have seen comments in the forum mentioning viewing the source of the page and finding the physical id of the fields and then using that in the custom javascript file but this is a horrible solution to hardcode id's and also I have no interest looking up 80 id's in the source code.

    This seems like a pretty common need, why is there no obvious place I can see to do this in the DF setup?

    Please, any help would be appreciated!

    Thanks
    Ryan BakerinkUser is Offline
    river guide
    river guide
    Posts:1900
    Avatar

    --
    09-06-2013 05:02 AM
    Hello Rob,

    I agree, it can be unfortunate that the Submit JavaScript doesn't support tokens.

    What you may want to try is creating a custom Submit button and hiding the original Dynamic Forms submit button. This way you can embed JavaScript into the OnClick event of your custom Submit Button. Creating a custom Submit Button requires that you use the Question Type Text/HTML, and I know that tokens will render in this control so long as the Question has a lower sort order than the control you're referencing it from.

    So try creating a custom Submit Button and let me know if this works for you:
    http://www.datasprings.com/news/blo...mit-button

    This blog contains the techniques needed to accomplish what I mentioned above.

    Please let me know if you have any questions.

    Thanks,

    Ryan
    RobUser is Offline
    skipping stones
    skipping stones
    Posts:8
    Avatar

    --
    09-06-2013 05:37 AM
    Thanks Ryan. I am not sure if I am doing this correctly but the way I set it up (according to your instructions, I believe), I get a Javascript error of undefined for A1_FieldID). A1 is the shortname for one of my radio button fields. Here is the code for the custom submit button:

    input type="button" value="Submit Form" onclick="alert(funcRadioCalc($(A1_FieldID)));__doPostBack('dnn$ctr2977$DynamicForms$btnSave','');"

    So it seems maybe DF is not handling the A1_FieldID token in the custom html's submit button. The custom submit button has the highest sort order of all the other controls since it needs to be positioned last on the page. I have no client side events set up for any of the 80 questions that appear on this form. I don't think I need any - all I want to do is intercept the form submission to do some calculations to fill in hidden fields, and then have DF take over, saving the form and emailing the results.

    Have I set this up improperly?

    Thanks for your assistance!!
    Ryan BakerinkUser is Offline
    river guide
    river guide
    Posts:1900
    Avatar

    --
    09-06-2013 05:40 AM
    Hello Rob,

    What if you use a simple JavaScript alert like so:

    alert($(A1));

    Is a JavaScript error invoked? Or does a popup window appear with a value in it?

    Please let me know.

    Thanks,

    Ryan
    RobUser is Offline
    skipping stones
    skipping stones
    Posts:8
    Avatar

    --
    09-06-2013 05:51 AM
    Unfortunately yes, I get the following error from Firebug's Javascript console: "ReferenceError: $A1 is not defined"

    It seems I remember reading in the forum something about the fact that tokens are not accessible unless some Javascript is placed in the associated control's client side event. Someone was trying to figure out why their token was not being processed in the "initial javascript" box in the module config, and the answer given was that something, even something useless such as just "var temp = 1" in the client side event for that field, would trigger DF to then render the tokens in the initial javascript. And he was right. I wonder if the problem I'm having here is something similar?
    Ryan BakerinkUser is Offline
    river guide
    river guide
    Posts:1900
    Avatar

    --
    09-06-2013 06:02 AM
    Hello Rob,

    Yes this is true when it comes to INitial JavaScript. Perhaps it's a similar issue.

    Can you place the following JavaScript into the client side event for A1.

    var nothing;

    Then save and retry this alert statement.

    Let me know if the results differ.

    Thanks,

    Ryan
    RobUser is Offline
    skipping stones
    skipping stones
    Posts:8
    Avatar

    --
    09-06-2013 06:24 AM
    When you asked me to try just alert($(A1)) I had mistyped it and left out a set of parenthesis. When I fixed it and tried it, I now get a pop-up but it is blank inside. So I went to view the source and for some reason DF stripped out the token entirely, leaving just "alert();". Is jQuery interfering here possibly? When I change it to alert($(A1_FieldID)) I then get A1_FieldID is undefined.

    In all cases when I add "var nothing;" to the client event it makes no difference in the result, I still get undefined errors.
    Ryan BakerinkUser is Offline
    river guide
    river guide
    Posts:1900
    Avatar

    --
    09-06-2013 06:32 AM
    Hello Rob,

    In this case, I really have no further suggestions, recommendations or ideas.

    The next step may be for you to provide us with temporary admin credentials so we can overlook this page. Then we'll be able to establish a fix or work around for this.

    Please send the URL to this Dynamic Form and admin credentials to me directly at:

    rbakerink (at) datasprings (dot) com

    I may not get to review this until mid-late next week.

    Please let me know if you have any questions.

    Thanks,

    Ryan


    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