Update Choice Control value with Javascript on Nintex Form

  • 27 September 2016
  • 11 replies
  • 73 views

Badge +3

Hi all,

I am trying to update a choice control - set to option buttons that has three choices, None, Risk Query, Request for Information. In advanced settings it has a variable set to RequestTypeNew.

I have a button on the form  that calls a JavaScript function called 'Check Query type" to set the Choice Control field to value to 'None' when clicked.

In the Check Query Type function I have the following:

NWF$('#' + RequestTypeNew).find('input:option[value="None"]').attr("checked","true");

but the Choice control with variable ReqestTypeNew is not updating when the button is pressed/form submitted. Instead the Choice Control field keeps the last value set in the form

I think the above JavaScript is wrong? 

Any help appreciated,

Darren


11 replies

Badge +3

I managed to work out the issue, in my original code I had input:option instead of radio. Correct syntax is below for anyone wanting to set the value of their choice control rendered as Option Buttons

NWF$('#' + RequestTypeNew).find('input:radio[value="None"]').attr("checked","true");
Userlevel 4
Badge +10

Hi Darren (or anyone else who wants to chime in),

I am trying to do something similar and am new to Forms and JS. I added your line of code (changing variable name) to mine and it did not do what I wanted. I have an undo button that should rest the content of a signature/comments panel by eliminating any input the user added. One of the controls I wan to reset is a choice control with two radio buttons. How would I make the choices null or both false regardless of what is currently chosen? Let me know if I am unclear or you need more info.

function resetSignatureSysAdmin() {
    NWF$('#'+ jsvar_SysAdminAction).find('input:radio[value="None"]').attr("checked","true");
    NWF$('#'+ jsvar_SysAdminName).val("");
    NWF$('#'+ jsvar_SysAdminComment).val("");
    NWF$('#'+ jsvar_SysAdminSponsor).val("");
    NWF$('#'+ jsvar_SysAdminDate).val("");
};‍‍‍‍‍‍‍

Thanks and Regards,

Patrick Kelligan

Userlevel 5
Badge +14

do you have an option labeled 'None' there?

if not change 'None' to a option label you want to be checked.

Userlevel 4
Badge +10

Hi Marian,

I do not. Actually, I was mistaken. They are not radio buttons but check boxes. So sorry fior the confusion. The two choices read "Sponsored" and "Provisioned". When I run my function, I want the both to be "False" or unchecked.

How would I accomplish this?

Thanks and Regards,

Patrick

Userlevel 4
Badge +10

Hi Marian,

Thanks for your response. I was able to figure it out. Here is what works with my check boxes:

function resetSignatureSysAdmin() {
    NWF$("#"+ jsvar_SysAdminAction).find("input:checkbox[value='Sponsored']").attr("checked",false);
    NWF$("#"+ jsvar_SysAdminAction).find("input:checkbox[value='Provisioned']").attr("checked",false);
    NWF$('#'+ jsvar_SysAdminName).val("");
    NWF$('#'+ jsvar_SysAdminComment).val("");
    NWF$('#'+ jsvar_SysAdminSponsor).val("");
    NWF$('#'+ jsvar_SysAdminDate).val("");
};

Thanks,

Patrick

Badge +3

Hi,

I am trying something similar. I want to clear a choice field so neither of the two options are sleected,.

This set the value ok.

NWF$('#' + appplicationUsedID).find('input:radio[value="Yes we still use this application"]').attr("checked","true");

This does not clear the value.

NWF$('#' + appplicationUsedID).find('input:radio[value="Yes we still use this application"]').attr("checked","false");

Any help appreciated.

Ian

Userlevel 4
Badge +10

Hi Ian,

In the configuration of your choice control, what do you have the display format set to; Check Boxes, Drop Down List, List or Option Buttons? OR, is your choice control bound to a list field with a choice data type... in that case what is the list field configured to?

Regards,

Patrick

Badge +3

Hi,

Radio buttons.

Cheers

Ian

Userlevel 4
Badge +10

Try this line Ian...

NWF$('#' + appplicationUsedID).find("input:radio[value='Yes we still use this application']").attr("checked",false);
Badge +3

Smashing that worked :-)

Userlevel 4
Badge +10

Good to hear! Did you see the difference?

Reply