How can I set Choice control value when in Option button display format

  • 22 August 2017
  • 8 replies
  • 8 views

Badge +3

I am able to get the value of the selected option of a choice control using:

function getCh1Val() { alert(NWF$('#'+cidCh1 + ' input:checked').val()); }

But I can't seem to set the value of the choice control when it is in option button display format. If I change it to drop down list format I can get and set the value with no problem.


8 replies

Userlevel 5
Badge +14

try following

NWF$('#' + cidCh1).find('input:radio[value="Yes"]').attr("checked","true");

‌  ‌ set choice value‌ set radio value‌ set choice option value

Badge +3

Thank you for your response Marian, I really appreciate it!

When I tried it at first it didn't work. So I went back and set Render as buttons to No and it worked perfect.If I have to I can change them but I really don't want to. I have four forms with about 350 choice controls all being rendered as buttons. We picked them because the forms are being filled out on a tablet with a finger and they are the easiest for them to select. Do you know what it would be if they are rendered as buttons?

Userlevel 5
Badge +14

I'd recommend you test it on your own, it may differ on each mobile platform.

Badge +3

OK, I did a clean test and removed the tablet from the picture completely.

I created a new list with a choice column and opened form designer. I added a button and put the one line of code you provided above. I opened the form and sure enough clicking the button set the proper button on the choice control exactly as you said. However, when I change render as buttons to yes and open the form again - it does not set the button. This test was does on-prem, on a desktop PC in an SP2013 environment using Nintex Forms version 2.10.

Userlevel 5
Badge +14

try following

NWF$('#' + cidCh1).find('input:radio[value="Yes"]').click();
Badge +3

That did it. Thank you very much Marian. I really appreciate your assistance.

Badge

Hi All

 

I am new to Nintex. Please would you mind letting me know where this piece of code should be added or how it should be added and the variables which i need to change to my own controls?

 

Thank you

Badge +4

Awesome that worked like a charm

Reply