I've got a form with the following select box:
<fieldset id="workers_comp_info">
<p>
<label for="i_n_r_reason">Reason why Workers Comp Insurance is not required:</label>
<select name="i_n_r_reason" id="i_n_r_reason">
<option value="No employees">No employees</option>
<option value="1-2 employees">1-2 employees</option>
<option value="Other">Other(Specify reason)</option>
</select>
<input id="other_reason" name="other_reason" type="text" placeholder="Other Reason" />
</p>
</fieldset>
I've written the following jquery code to hide the "other_reason" text field unless "Other" is selected in the select box.
$('#i_n_r_reason').change(function() {
$('#other_reason').toggle($(this).val()=='Other');
}).change();
I am creating a jquery method called SubmitForm. I want to write something like this:
function SubmitForm() {
if ($('#i_n_r_reason').val()=='Other')
('#i_n_r_reason').val = ('#other_reason').val
('#account_form').submit();
}
When the user selects 'Other', the text field is displayed for them to enter a reason. I want this reason to override 'Other' when the user submits the form. But its not happening with this code. Any suggestions?