My HTML code is as:
<div id="detail">
<div class="d_left">
Page <strong>1</strong> of 107
</div>
<div class="d_center">
<table>
<tr>
<td><a href="#">Previous</a> | <a href="#">Next</a>
<img src="/webProject/store/images/arrow.png" align="absmiddle" alt="">
</td></tr></table>
</div>
<div class="d_right">
Sort by:
<select name="featured" size="1" id="item1">
<option>Featured Items1</option>
<option>Featured Items2</option>
<option>Featured Items3</option>
<option>Featured Items4</option>
</select>
</div>
</div>
Now, I want to read selected value from <select name="featured" size="1" id="item1">
.
How can I do this using JavaScript?
function delivery(x){
var country = x.value;
document.getElementById('lala').innerHTML = country;
}
<div id="lala"></div>
<form action="" method="post">
<select name="country" id="country" onChange="delivery(this)">
<option value='lala'>Select Country</option>
<option value='United_Kingdom'>United Kingdom</option>
<option value='Russia'>Russia</option>
<option value='Ukraine'>Ukraine</option>
<option value='France'>France</option>
<option value='Spain'>Spain</option>
<option value='Sweden'>Sweden</option>
</select>
</form>
Here is how i solved my problem for selecting eu countries (i have removed most of them to make my codes shorter).. as im new to javascript.. i still need to learn javascript libraries.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With