user85511
user85511

Reputation: 533

Html with javascript-search

I have a search application in html with javascript.In that i used select & option(select box).I want to retrieve the values from access database to selectbox.How can i do this with array?i also want to get the count of the option.The below not working correctly.How can i do this.any one knows please help me.Thank you.

var myselect=(selinstal.value);

for(var i=0;i<(select2.option.length);i++)
{
    myarray[i]=myselect;
    rs(myarray);  
    //document.write(rs(0));
}

<select id="Select2" style="width: 152px" name="selinstal">
    <option selected="selected"></option>
</select>

Upvotes: 0

Views: 104

Answers (2)

mays
mays

Reputation: 397

Devassy,

Your question is not very clear. If it is how to retrieve the values from access database to selectbox , you should prob do it at the server side code by enumerating the records over the select options.

If it is about how to find the total count of the options for the select, use what Ben has suggested.

document.getElementById("Select2").options.length

Also make sure that the above script executes after the select element is loaded in to the DOM ie after window.onload is invoked.

Upvotes: 0

Ben
Ben

Reputation: 11208

It can be done by something like this.

I haven't tested it, but it should do..

To get the selected option: document.getElementById("Select2").options[document.getElementById("Select2").selectedIndex].value

To get an array with options: document.getElementById("Select2").options

Upvotes: 1

Related Questions