How to get value from select tag in variabel.
i have created an div in my aspx page
<div id="myDivResult"></div>
In this in my javascript i create an select tag with option
Like this
var selectList = document.createElement("select");
var myDiv = document.getElementById("myDivResult");
while (myDiv.hasChildNodes()) {
myDiv.removeChild(myDiv.firstChild);
}
myDiv.appendChild(selectList);
I also have created option from an array with some item to add to the select tag.
Like this
var free = "";
for (var j = 0; j < bookedFreeTimes.length; j++) {
free = bookedFreeTimes[j];
var array = new Array(free);
for (var k = 0; k < array.length; k++) {
var option = document.createElement("option");
option.text = array[k];
selectList.appendChild(option);
}
}
My problem is next how could i get value from my select tag in my next function
function getItem()
{
var listItemFromAndToDate = document.getElementById('myDivResult').value;
}
I have tried like this but the value gets undenified?
What should i use here instead to get the value from the select tag?