can't set default selected option using value

208 Views Asked by At

I make dropdown using select option tag. Now I confused about how to custom the default selected option. I want to set the default selected option for this option uu

I've tried using "selected" attribute but it doesn't work when I set the value="uu".

<div>
<select class="form-control" id="c" name="c"  required>
    <option value="u" selected>uu</option>
    <option value="m">mm</option>
    <option value="n" >nn</option>
</select>
</div>

here is the result result set value="uu"

But if i set the value to value="" it works fine.

<div>
<select class="form-control" id="c" name="c"  required>
    <option value="" selected>uu</option>
    <option value="m">mm</option>
    <option value="n" >nn</option>
</select>
</div>

here is the result, it can show the option uu result set value=""

maybe there is something that i should do to fix this? thankyou

1

There are 1 best solutions below

0
Nisha On

It's showing uu here.

 <div>
        <select class="form-control" id="c" name="c" required>
            <option value="u" selected>uu</option>
            <option value="m">mm</option>
            <option value="n">nn</option>
        </select>
    </div>