AnsweredAssumed Answered

Forms 365: JavaScript to Set Option Buttons only works once

Question asked by barryc Champion on May 24, 2018
Latest reply on May 25, 2018 by barryc

I am trying to set the value of a choice control, rendered as option (radio) buttons using JavaScript...the JavaScript is called by clicking a button (client click).

 

Example function is below. This function works properly once, and once only per form load. After initially successfully setting the option button, any subsequent click of the button does not set it back to "Stage 2 - Proposal and Corrective Actions". However the 2 alerts on either side of that line do pop up.

 

So the function is successfully called each time the button is clicked, the actual value setting only works on the first click. Why?

 

function Stage2() { 
alert("Starting Stage 2 function");
NWF$('#' + varStage).find('input:radio[value="Stage 2 - Proposal and Corrective Actions"]').attr("checked","true").change();
alert("Ending Stage 2 function");
return false;
}

Breaking down the function:

 

varStage - is the JavaScript variable for the choice control

.change() is used as otherwise rules based on this value being set do not fire

 

I have also tried the below line but the behaviour is identical:

NWF$('#' + varStage).find('input:radio[value="Stage 2 - Proposal and Corrective Actions"]').attr("checked","checked").change();

Outcomes