Fingashpitzzz
Fingashpitzzz

Reputation: 169

How to indicate the default value in a dropdown menu

I have a form containing a number of dropdown menu's. Each dropdown has a default option. I know how to set this default value, but I'm not sure on how to indicate this value, so that people know that is the default.

I create the dropdown like this

<?php
    for ($mismatch = 0; $mismatch <= 3; $mismatch ++) {
        if($mismatch == 1){
            $select_mismatch .= "<option value = $mismatch selected > ".$mismatch." (default) </option>";
        } else {
            $select_mismatch .= "<option value = $mismatch > ".$mismatch." </option>";
        }
    }
?>

So on the web page, the dropdown looks like:

option 1 (default)
option 2
option 3

So now I indicate the default value by just adding (default) to it. Does anyone know another way to indicate this which is a bit more pleasing to the eye?

Upvotes: 0

Views: 987

Answers (3)

Todd Mark
Todd Mark

Reputation: 1885

you can use a CSS class to indicate.

JSFiddle DEMO

<select name="" id="">
    <option value="1">please choose</option>
    <option value="2" class="default">default</option>
    <option value="3">other item</option>
</select>

.default{
    background: #000;
    color: #fff;
}

Upvotes: 0

chirag
chirag

Reputation: 583

Try this:

<select data-placeholder="Please Select" class="required select-full" name="status" >
                <option value=""></option>
                <option value="1" <?php if ($post['status'] == "1") { ?> selected="true" <?php } ?>>Enable</option>
                <option value="0" <?php if ($post['status'] == "0") { ?> selected="true" <?php } ?>>Disable</option>
            </select>

Upvotes: 1

Katler
Katler

Reputation: 507

maybe like this?

<select name="test"> 
    <option> 
    1 
    </option> 
    <option> 
    2 
    </option> 
    <option selected> 
    3 
    </option> 
    <option> 
    4 
    </option> 
    <option> 
    5 
    </option> 
</select> 

Unless you mean to a drop down hover menu? if so then you could add a colour to the default option.

Upvotes: 0

Related Questions