Angripa
Angripa

Reputation: 157

how to get value from list box in html

This is an example,

<select>
    <option value=1>Cars</option>
</select>

How i can get the value of selected "1" and value in list box "Cars"?

Upvotes: -1

Views: 25481

Answers (2)

Vijay
Vijay

Reputation: 8451

try out this

<select id="selectID">
    <option value=1>Cars</option>
</select>

using javascript

var e = document.getElementById("selectID");
var strUser = e.options[e.selectedIndex].value;

Upvotes: 3

Jay Shukla
Jay Shukla

Reputation: 5826

jQuery("#sltbox").find("option[value=1]").attr("selected","selected")

Give id as sltbox to your select tag.

Upvotes: 2

Related Questions