I have a pair of inputs of type radio like so:
<label>YES</label>
<input type="radio" name="uscitizen" id="uscitizenyes" value="YES" required />
<label>NO</label>
<input type="radio" name="uscitizen" id="uscitizenno" value="NO" />
To set the value of a Sharepoint 2010 List item ('ptli_USCitizen' in this case), is this the best way to accomplish it:
oListItem.set_item('ptli_USCitizen', ($('uscitizenyes').val() == 'YES'));
...or is there a more "accepted patternful" way?
This will work.
oListItem.set_item('ptli_USCitizen', ($('[name="uscitizen"]:checked').val() == 'YES'));
But the best way to handle a boolean value in the User Interface is a Checkbox rather than radio buttons.
Us Citizen: <input type='checkbox' id='uscitizen' name='uscitizen' />
Then use:
oListItem.set_item('ptli_USCitizen', ($('#uscitizen').is(':checked'));