DarkSideUser
DarkSideUser

Reputation: 565

dynamic select box at load webpage

Now I have a static select box, something like this:

<label>Select name: </label>
<select id="option" onchange="optionSelected();">
    <option value="-1">=== Select name ===</option>
    <option value="1">Name 1</option>
    <option value="2">Name 2</option>  
    <option value="0">All names</option>  
</select>

But I want that number of options could be changed. I have a file with data and webpage loads it during loading. So I now the info I want to show and the number of options. This info will not change. If it is changed, the changes just will be shown the next time webpage is loaded. I have the info in one array, so I can make a for to take all names and using length property, know the size.

I checked some tutorials about ajax but I don't understand them very well. I am using jquery in my webpage.

How can I do it? English is not my first languaje and I don't know the correct words to search in google, I always find many tutorials but not about what I need.

Upvotes: 0

Views: 211

Answers (1)

muthu
muthu

Reputation: 5461

Hi this is the basic example of creating a dynamic select box from database using ajax. It may useful for you

Upvotes: 1

Related Questions