I have a select field with a list of names, after selecting one of them I have to assign a value in the database to an input field.
So I understand you want to get the value
of your select
field and play it to a input
field if it is not that, comment that I edit the answer to fit better
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script><scriptsrc="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script type="text/javascript">
$(document).on('change', '.get-placa', function () {
var value = $(this).val();
$('.close').trigger('click');
$('.campo2').val(value);
});
</script>
<div class="col-lg-3">
<select class="form-control get-placa" type="text" name="campo1" maxlength='4'>
<option></option>
<option value='Campo1'>Campo1</option>
<option value='Campo2'>Campo2</option>
</select>
</div>
<div class="col-lg-3">
<label for="ex1">Pegando Value do Select:</label>
<input type="text" class="form-control campo2" maxlength="14" name="campo2"><br><!-- Input CNPJ -->
</div>