I have a select tag:
//$places = Array("A", "B", "C");
<select onchange="calculate()" class="form-control" id="from" name="from">
<?php foreach($places as $place){
echo '<option value="'.$place.'">'.$place.'</option>';
} ?>
</select>
And I need to get the selected option's value with js. I tried like this:
function $(id){return document.getElementById(id);}
function calculate() {
var from = $("from").value;
var to = $("to").value;
console.log(from);
console.log(to);
.
.
.
}
But that gives back 'undefined'. Any Ideas?