cancel
Showing results for 
Search instead for 
Did you mean: 
Workflow Hero

Value of Multiple Radio Buttons Within a Conditional Statement

Jump to solution

What is wrong with these syntax, because it's not working?

if (NWF$('#' + Question1).find("input:checked").val("Yes")) {
   NWF$('#' + AssessmentValue).val('Completed');
}

if (NWF$('#' + Question1).find("input:checked").val()=="Yes" ) {
   NWF$('#' + AssessmentValue).val('Completed');
}

Labels: (1)
0 Kudos
Reply
11 Replies
Workflow Hero

Re: Value of Radio Button in a Conditional Statement

Jump to solution

Maybe a stupid question but are Question1 and AssessmentValue the values specified in each control's Advanced setting "Client ID JavaScript variable name"?

0 Kudos
Reply
Workflow Hero

Re: Value of Radio Button in a Conditional Statement

Jump to solution

And, in addition to Jean-Pierre question, what kind of fields are associated to Question1 and AssessmentValue? If one of them is the "outcome" of a task, its values are numbers, non the text value associated to it..

0 Kudos
Reply
Workflow Hero

Re: Value of Radio Button in a Conditional Statement

Jump to solution

Yes they are.

0 Kudos
Reply
Workflow Hero

Re: Value of Radio Button in a Conditional Statement

Jump to solution

What I'm trying to do really is to have the script mark the AssessmentValue as "Completed" when a series of questions are answered in one or more accepted combinations. Say for e.g.

If Question1="Yes" and Question2="No" and Question3="No", or

If Question 1="Yes" and Question2="Yes" and Question3="Yes" and Question="No"

then the assessment is finished and the AssessmentValue should be "Completed".

I'm not sure how to do this via JQuery so any help will be appreciated. Looking at my initial script below...I think an array for all the questions is required at some point?

NWF$('#' + Question1).click(function() {
if (NWF$('#' + Question1).find("input:checked").val("Yes")) {
NWF$('#' + AssessmentValue).val('Completed');
}
})

0 Kudos
Reply
Workflow Hero

Re: Value of Multiple Radio Buttons Within a Conditional Statement

Jump to solution

With "NWF$('#' + Question1).find("input:checked").val("Yes")" one would set the radio button or checkbox. What you need to use is "if (NWF$('#' + Question1).find("input:checked").val() == "Yes") {}"

Reply
Workflow Hero

Re: Value of Multiple Radio Buttons Within a Conditional Statement

Jump to solution

As for the AssessmentVlaue. If this is a choice field as well, then you may have to set the internal option value to checked as well. If AssessmentValue is just a text then your instruction should work just fine.

0 Kudos
Reply
Workflow Hero

Re: Value of Multiple Radio Buttons Within a Conditional Statement

Jump to solution

Thank you. AssessmentValue is text field. Are you able to help me further with this JQuery? I can't seem to get it to work in Nintex.

var Questions = [
NWF$('#' + Question1),
NWF$('#' + Question2)
]

$(Questions).each(function(i) {
$(this).click(function() {
if (NWF$('#' + Question1).find("input:checked").val() == "Yes" && NWF$('#' + Question1).find("input:checked").val() == "Yes" ) {
NWF$('#' + AssessmentValue).val('Completed');
}
else {

NWF$('#' + AssessmentValue).val('');
}
})
})

0 Kudos
Reply
Workflow Hero

Re: Value of Multiple Radio Buttons Within a Conditional Statement

Jump to solution

Are you only checking Question1 for all Questions? The if "ands" the same condition twice (Question1), so I guess the 2nd one should be for Question2 (-> if (NWF$('#' + Question1).find("input:checked").val() == "Yes" && NWF$('#' + Question2).find("input:checked").val() == "Yes" ))

Have you tried $(this).change() in stead of $(this).click()?

0 Kudos
Reply
Workflow Hero

Re: Value of Multiple Radio Buttons Within a Conditional Statement

Jump to solution

Yeah I realised it should be Question 2 and not 1.

$(this).change() also didn't work; I have used $(this).click() in an earlier function and it works.

0 Kudos
Reply