input inside select

insert an input tag "inside" a select tag

by gdfclub

HTML

<table>
  <tr>
      <td>
        <input id="input1" hidden="hidden" placeholder="input data">
        <select onchange="selection()" id="select1">
          <option value="-1"></option>
          <option value="0">-make your own choice-</option>
          <option value="1">choice 1</option>
          <option value="2">choice 2</option>
        </select>
      </td>
  </tr>
</table>

CSS

td{
  width: 170px;
  max-width: 170px;
  overflow: hidden;
  white-space: nowrap;
}

input{
  width: 164px;
}

JavaScript

function selection(){
	var selected=document.getElementById("select1").value;
  if(selected==0){
  	document.getElementById("input1").removeAttribute("hidden");
  }else{
  	//elsewhere actions
  }
}