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?