Make a form drop down open a new text field

Hi there,

I wanted to see if anyone knows a way to add a new field when a specific drop down item is selected? Specifically, I am trying to make it when someone selected the option “Other” from my dropdown that a text field would appear below to fill out.

I found some similar questions in the forum but not for a dropdown.

Thanks for the help!

Hello!

You can do this with some simple jQuery. I would wrap the “Other” field in a div, or assign it a specific ID or class (#other). Replace #form_select with the ID of your dropdown menu.

$(function () {
  $("#form_select").change(function() {
    var val = $(this).val();
    if(val === "other") {
        $("#other").show();
    }
    else if {
        $("#other").hide();
    }
  });
});
2 Likes

Awesome, this is perfect thanks so much!!

1 Like

where do you put the code tho? inside the page, im not sure if Im not naming the things properly but it doesnt seem to execute the query…

Thanks!

If anyone is looking for a solution, changing the code above to an if/else statement (instead of else if) worked for me:

$(function () {
      $("#form_select").change(function() {
        var val = $(this).val();
        if(val === "other") {
            $("#other").show();
        }
        else  {
            $("#other").hide();
        }
      });
    });