Java 'null' error from hidden questions
Last Post 02-18-2010 11:36 AM by David To. 3 Replies.
AddThis - Bookmarking and Sharing Button
Author Messages
THSUser is Offline
going with the flow
going with the flow
Posts:48
Avatar

--
02-17-2010 09:03 PM

    I have a form that successfully totals options from radio button questions (it's an event registration form) and processes through PayPal with no problems. However, when questions are setup as hidden that are made visible from a question event (for example, the registrant first selects whether they're a member or not which then displays the questions and pricing for members and vice versa for non-members to get non-member questions and pricing), I'm getting js errors like this:


    Message: 'null' is null or not an object
    Line: 65
    Char: 1
    Code: 0
    URI: https://www.../Portals/0/Dynamic-Forms_Module_455.js

    My assumption is this is due to questions that remain hidden which are 'null' which of course keeps the form from doing the totaling. The script that's doing the totaling is as follows:


    $(TotalMemTrack) = funcRadioCalc($(MemTrack_FieldID))
    $(TotalLunchMem) = funcRadioCalc($(LunchMem_FieldID))
    $(TotalLunchNonMem) = funcRadioCalc($(LunchNonMem_FieldID))

    $(GrandTotalHidden) = parseFloat($(TotalLunchMem)) + parseFloat($(TotalMemTrack)) + parseFloat($(TotalLunchNonMem))

    $(Amount) = formatCurrency($(GrandTotalHidden))

    $(PayPalTotal) = toTwoDecimals($(GrandTotalHidden))

     

    So, my thought was to setup If/Else statements in place of the code that's just pulling what's being sent by the question so a zero is plugged into the script that does the totaling instead of a null - like this:

     

    if (funcRadioCalc($(LunchMem_FieldID)) == null) {
    $(TotalLunchMem) = 0;
    } else {
    $(TotalLunchMem) = funcRadioCalc($(LunchMem_FieldID));
    }

     

    However, I'm still getting the 'null' error. Another thought was I needed to expand the If part a bit more to include a zero length being sent by the hidden question like this:

     

    if (funcRadioCalc($(MemTrack_FieldID)).length==0)||(funcRadioCalc($(MemTrack_FieldID))==null) {
    $(TotalMemTrack) = 0;
    } else {
    $(TotalMemTrack) = funcRadioCalc($(MemTrack_FieldID));
    }

     

    But, I don't know if this is the correct syntax or what. Am I on the right track or is there another way to ignore the nulls from the hidden questions?

    David ToUser is Offline
    river guide
    river guide
    Posts:2719
    Avatar

    --
    02-18-2010 07:06 AM
    HI, any fields that you set "hidden until made visible by a question event" or "Hide from roles" will not be rendered on the page, so client side javascript will not know it exists and also that field will not be saved to the database unless, of course, it gets triggered visible first and then client side javascript can then act on it.

    So your if else statement:
    if (funcRadioCalc($(LunchMem_FieldID)) == null) {
    $(TotalLunchMem) = 0;
    } else {
    $(TotalLunchMem) = funcRadioCalc($(LunchMem_FieldID));
    }
    will error out since the field "LunchMem" is still hidden on page load. What you want to do is set $(TotalLunchMem) = 0 on page load under Module Configuration / Initial Javascript. Don't reference any radio button fields yet on page load. Then proceed with your javascript that you had on the radio button fields. I think this will work out for you. -- David
    THSUser is Offline
    going with the flow
    going with the flow
    Posts:48
    Avatar

    --
    02-18-2010 11:22 AM

    Hi David -

    OK, that makes sense. So, what is the syntax for setting something to zero on page load?

    David ToUser is Offline
    river guide
    river guide
    Posts:2719
    Avatar

    --
    02-18-2010 11:36 AM
    $(TotalLunchMem) = 0;

    in module configuration / javascript / initial javascript

    -- David


    ---
  • 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