Adding "other" field to checkbox field - redux!

The issue of adding an “other” option to checkbox fields has been posted here numerous times. I recently had the issue myself. The option of adding a textbox field and conditionally making it visible was not working for me, because I was using a 2-column format for both fields and choices within fields, and the text field was appearing in the wrong column. Here’s how I solved it:

  • I created a checkbox field and included an “Other” choice.
  • I created a text field to hold “other” answers and made its display conditional on the selection of the “Other” choice. This field does not have a visible label or description, although one could do that.

Then I added a little jQuery. I created a teensy function:

		function otherchk(formNo,otherid,chkid)	{
			$('#field_'+formNo+'_'+otherid).appendTo('#field_'+formNo+'_'+chkid+' .ginput_container_checkbox');
			return;
		}

otherid is the field number of the text field and chkid is the field number of the checkbox field. formNo is the form number. I implemented this function on $(document).ready().

This option moves the “other” text field into the end of the choices list in the checkbox field. My checkbox field offered choices in two columns, and the Other text field spans both columns, which is just how I wanted it.

I hope this function helps somebody!

2 Likes