Also wondering the same...smeholick, did you ever find a solution for this?
MatthewM The transposition would have been the easiest solution, but unfortunately I get a 0 for the count, so I don't think it works. Thank you for the suggestion, though!Sateesh darelS That worked. Thank you.
Good to know, although it does look like all of the fields are there. To clarify, their values are set with JS. The fields themselves are created with the standard survey fields. Thanks
Got it, thank you! Below is what I came up with and it seems to be working! Appreciate your help. const allGrants = [ {rc:"${q://1_QID69/SelectedChoicesRecode}", val:"${q://1_QID70/ChoiceTextEntryValue}"}, ..... var sum = 0; allGrants.forEach((rc, index) => { if (allGrants[index].rc == 1) { sum += Number(rc.val); } }); //set HTML jQuery("#QID75").html(" Total Costs: $" + sum);
Hi Tom,I'm sorry for not responding sooner, as I appreciate your direction and was able to use it to come up with some code that is close to giving me what I need. Beginner js user here so sorry if I've missed anything obvious! but what I'm experiencing with the code below is that according to my console log there's one less name:value pair being accounted for in my for loop and therefore my sum. Is my for loop the problem, or perhaps my object excludes a pair?//sum up direct costs of "Funded" only grantsfunction sum(grants) { var sum = 0; for (var status in grants) { console.log(status); //if status = 1 (funded recode val) if (status = 1) { sum += parseFloat( grants[status] ); } } return sum; }//pipe all costs and answer values from all loops into objectvar all_grants = { "${q://1_QID69/SelectedChoicesRecode}":"${q://1_QID70/ChoiceTextEntryValue}}", "${q://2_QID69/SelectedChoicesRecode}":"${q://2_QID70/ChoiceTextEntry
Thank you both. I will most likely use the first approach in order to avoid using embedded data.
Already have an account? Login
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.
Sorry, we're still checking this file's contents to make sure it's safe to download. Please try again in a few minutes.
Sorry, our virus scanner detected that this file isn't safe to download.