Answer summary:
Daryl wanted to auto-fill certain form fields with "See Prior Filing" when the form submitter selected the "NO" option for a radio button field. This requires some JavaScript. To do this, you'll add the radio class to the radio button and the autofill class to each field you want to fill with "See Prior Filing." Here's the code for that.
$(document).ready(function () {
$('.radio input').change(function () {
$(".radio input:checked").each(function(){
if ($(this).val() == "No")
{
$('.autofill input').val('See Prior Filing');
}
else if ($('.autofill input').val() === 'See Prior Filing')
$('.autofill input').val('')
})
})
})
The code above works if the user selects an option from a checkbox or radio button field and it automatically fills fields that aren't in a collection or table. Using the '#q283 input' selector works for radio buttons and checkboxes. For drop-down fields, use '#q283 select' as the selector. Like so:
$('#q281 select').change(function () {
if ($(this).val() == "No") {
$('.autofill input').val('See Prior Filing');
if ($('input[name="routingResumeId"]').val() == "") {
$('#q304').hide(); //section ID
}
}
else if ($('.autofill input').val() === 'See Prior Filing')
$('.autofill input').val('')
$('#q304').show(); //section ID
})
Because the fields within a collection or table are repeatable, they have a special ID attribute that ensures their uniqueness.
Here's the code to fill fields within a table. If the user selects no, the table fields are filled with "See Prior Filing," the fields become read-only, and the Add row button is hidden.
$(document).ready(function () {
$('#q283 input').change(function () {
$("#q283 input:checked").each(function () {
if ($(this).val() == "No") {
$('#q68 tbody tr').each(function () {
$(this).find('.autofill input').each(function () {
$(this).val('See Prior Filing');
})
})
$('#q68 input').attr('readonly', 'true'); //table selector
$('#q69').hide(); //table add button selector
}
else
$('#q68 tbody tr').each(function () {
$(this).find('.autofill input').each(function () {
if ($(this).val() === 'See Prior Filing')
$(this).val('');
})
$('#q68 input').removeAttr('readonly'); //table selector
$('#q69').show(); //table add button selector
})
})
})
})