Dima Dima - 7 months ago 22
jQuery Question

How to insert a field after check the value of a field

I am searching for a way to insert one or more fields into HMTL after checking the value from a other field. Here is my HTML:

<select id="status" name="status">
<option value="1" style="background-color: #cdeb8e">freigegeben</option>
<option value="2" style="background-color: red">gesperrt</option>
<option value="3" style="background-color: yellow">Rückfrage erforderlich</option>
<option value="4" style="background-color: yellow">Muster</option>

status > 1
I want to add
<input type="text" />
after the
. How can I do that?

Kld Kld

You can check after the select changes and show/hide the input according to the selected value.

$('#status').change(function() {
  if ($(this).val() > 1) {
  } else {
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>

<select id="status" name="status">
  <option value="1" style="background-color:#cdeb8e">freigegeben</option>
  <option value="2" style="background-color:red">gesperrt</option>
  <option value="3" style="background-color:yellow">Rückfrage erforderlich</option>
  <option value="4" style="background-color:yellow">Muster</option>

<input type="text" style="display:none;" id="myInput" />