-2

I need some help with changing the placeholder of an input via <select>,

I mean I need to change the placeholder of an input if the option of the <select> has been changed

My code:

<select id="select" name="se">
   <!-- if this is chosen placeholder will be 'you have chosen option n1' !-->
   <option value="1">option 1</option>
   <!-- if this is chosen placeholder will be 'you have chosen option n2' !-->
   <option value="2">option 2</option>
   <!-- if this is chosen placeholder will be 'you have chosen option n3' !-->
   <option value="3">option 3</option>
</select>
<input type="text" id="inp" name="choosen">
Ibrahim Khan
  • 20,616
  • 7
  • 42
  • 55
script0r
  • 119
  • 2
  • 9

1 Answers1

0

Try this :

$('select').on("change",function()
{
   $('#inp').val("you have chosen option n" + $.trim(this.value));
}).change();

Example : https://jsfiddle.net/DinoMyte/zcL12b1u/1/

DinoMyte
  • 8,737
  • 1
  • 19
  • 26