I'm trying to get the value of a selected element and show it at the console. I've searched everything, tried everything and it's not working. value1 I get it but value2 and 3 not.
If you have any other recommendation (besides using Jquery to do this, please do it)
Check it out
$(document).ready(function() {
$("button").click(function() {
var value1 = $("#name-input").val();
var value2 = $("#place-input").filter(":selected").text();
var value3 = $("#tecnico-input").find(":selected").text();
console.log(value1 + ' ' + value2 + ' ' + value3);
});
});
<form>
<div class="input-group">
<span class="input-group-addon" id="basic-addon1">Name:</span>
<input type="text" class="form-control" placeholder="Ex.: John" aria-describedby="basic-addon1" id="name-input">
</div>
<div class="form-group">
<label for="sel1">Place:</label>
<select class="form-control" id="sel1" id="place-input">
<option value="1">Fixed</option>
<option value="2">Mobile</option>
</select>
</div>
<div class="form-group">
<label for="sel2">Technician:</label>
<select class="form-control" id="technician-input">
<option value="1">Brandon</option>
<option value="2">Justin</option>
<option value="3">Ryan</option>
<option value="4">Tyler</option>
</select>
</div>
</form>
I strongly appreciate the help.
$("#place-input").children().filter(":selected").text();,tecnico-input!=technician-input.