I had a user request to automatically fill in text in a required field based on the selection of a radio button on the page. The form that is being filled out is used by a hiring manager to document the decision process for a certain recruit. Since each position will only have one person hired, but typically more than one applying, the answer to the question, “Was this person hired?” will be “No” way more than it will be “Yes.” Therefore, a reason for the “No” is required.
In the relatively rare event that the candidate is hired, the reason for not selecting him becomes moot. But rather than trying to manipulate the “requiredness” of the text box, I wanted to automatically fill in “N/A” on the rare and happy occasion “Yes” is selected.
First, I needed to find the specific radio buttons in question. For some reason, the name of the choice column that generates radio buttons does not include the name of the column anywhere in the input of the button itself. Instead, the first choice looks like this:
<span class="ms-RadioText" title="Yes"><input id="ctl00_PlaceHolderMain_TaskForm_ff2_1_ ctl00_ctl00" type="radio" name="ctl00$PlaceHolderMain$TaskForm$ff2_1$ctl00$RadioButtons" value="ctl00" /><label for="ctl00_PlaceHolderMain_TaskForm_ff2_1_ctl00_ctl00">Yes</label> </span>
and the second choice looks like this:
<span class="ms-RadioText" title="No"><input id="ctl00_PlaceHolderMain_TaskForm_ff2_1_ ctl00_ctl01" type="radio" name="ctl00$PlaceHolderMain$TaskForm$ff2_1$ctl00$RadioButtons" ...