Miljan Ilic
Miljan Ilic

Reputation: 335

Make <select> option selected

I have an HTML form with list of countries, now in profile I want to make selected country that user selected when registered to site. I'm searhed google but I can't make anything works.

In profile I'm selecting Country Value from MySQL

Upvotes: 0

Views: 156

Answers (2)

Ajay Bijlani
Ajay Bijlani

Reputation: 52

If you want to set select statically then use this

<form>
  <select>
    <option value="value" selected="selected">01</option>
    <option value="value" >02</option>
  </select>
</form>

Or if you want to do dynamically then this may be helpful.
Hope this will work for you ...

Upvotes: 2

Quentin
Quentin

Reputation: 944568

Put a selected attribute in the option you want to be selected.

<option value="foo" selected> bar </option>

Upvotes: 2

Related Questions