0

I have one condition where I want to add text area when I select any option from select option. I have 4 to 5 options in my select box and I want one text area to be added when I select any option from my select box.

Here is my html:

<select name="menu-114" class="wpcf7-form-control wpcf7-select" aria-invalid="false">
   <option value="Select Category" selected="selected">Select Agent Name</option>
   <option value="Option 1">Mr. abc</option>
   <option value="Option 2">Mr. abc</option>
   <option value="Option 3">Mr. abc</option>
</select>
<textarea></textarea>

I want to add the textarea when I select any option from above select box.

See my fiddle

jcuenod
  • 55,835
  • 14
  • 65
  • 102
shakil
  • 51
  • 5

1 Answers1

0

I can't think why you would want to but here's how I would do it:

Listen for the change event on your select element and use $.appendTo

$(document).on('change', 'select[name=menu-114]', function(){
    $("<textarea>").appendTo(".agent_select_wrap");
    //$(this).val() will return the value attribute of the select
});

Here's a working fiddle

jcuenod
  • 55,835
  • 14
  • 65
  • 102