/    Sign up×
Community /Pin to ProfileBookmark

Should I add Blank Values On Dropdowns Or Not And Which Drop Down You Prefer ?


Folks,

  • 1. Out of these 2 samples, which one you prefer ?
  • [code]
    <input type=”radio” name=”tos_agree” id=”tos_agree_yes” value=”yes”>
    <label for=”tos_agree_yes”>Yes:</label>
    <input type=”radio” name=”tos_agree” id=”tos_agree_no” value=”no”>
    <label for=”tos_agree_no”>No:</label>
    <br>
    [/code]

    [code]
    <label for=”tos_agreement”>Agree to TOS or not ?</label>
    <select name=”tos_agreement” id=”tos_agreement”>
    <option value=”yes”>Yes</option>
    <option value=”no”>No</option>
    </select>
    [/code]

    2.
    Once had a drop down issue. Can’t exactly what it was. It was solved by adding a blank dropd own option value at the top. What wasn’t working ? How wasn’t working ? I can’t remember. Either php had difficulty reading user input or the drop down was not showing any options. And so, I had to add a blank value at the top.

    So, something like this wasn’t working …

    [code]
    <label for=”tos_agreement”>Agree to TOS or not ?</label>
    <select name=”tos_agreement” id=”tos_agreement”>
    <option value=”yes”>Yes</option>
    <option value=”no”>No</option>
    </select>
    [/code]

    Added a blank value, at somebody’s advice, to get it to work. I think it was something like this, if I remember correctly:

    [code]
    <label for=”tos_agreement”>Agree to TOS or not ?</label>
    <select name=”tos_agreement” id=”tos_agreement”>
    <option value=” “>Select here</option>
    <option value=”yes”>Yes</option>
    <option value=”no”>No</option>
    </select>
    [/code]

    Or, maybe it was something like this:

    [code]
    <label for=”tos_agreement”>Agree to TOS or not ?</label>
    <select name=”tos_agreement” id=”tos_agreement”>
    <option value=” “></option>
    <option value=”yes”>Yes</option>
    <option value=”no”>No</option>
    </select>
    [/code]

    Was this a php or html 5 issue ? Can anybody fugure ?

    All I remember slightly that there was a blank value.
    I been going through my php files to find that particular file to jog my memory but I failed to find it.

    Can you folks explain to me if a blank value is required or not ? What is the benefit/disaster of adding it and how should the blank value be added ? Show me an example.

    Thank You

    to post a comment
    PHP

    2 Comments(s)

    Copy linkTweet thisAlerts:
    @daveyerwinJul 12.2020 — @developer_web#1620481

    maybe like this instead of blank option ...

    ``<i>
    </i>&lt;!DOCTYPE html&gt;
    &lt;html&gt;
    &lt;head&gt;
    &lt;/head&gt;
    &lt;body&gt;
    &lt;form&gt;
    &lt;label for=color&gt;Choose a Shirt Color:&lt;/label&gt;&lt;br&gt;
    &lt;select id=color name=shirt_color&gt;
    &lt;option value=none selected&gt;please select color&lt;/option&gt;
    &lt;optgroup label="Main Colors"&gt;
    &lt;option value=blue&gt;Blue&lt;/option&gt;
    &lt;option value=red&gt;Red&lt;/option&gt;
    &lt;option value=yellow&gt;Yellow&lt;/option&gt;
    &lt;/optgroup&gt;
    &lt;optgroup label="Other Colors"&gt;
    &lt;option value=purple&gt;Purple&lt;/option&gt;
    &lt;option value=green&gt;Green&lt;/option&gt;
    &lt;option value=orange&gt;Orange&lt;/option&gt;
    &lt;/otpgroup&gt;
    &lt;/select&gt;
    &lt;input type=reset&gt;
    &lt;button&gt;Submit&lt;/button&gt;
    &lt;/form&gt;
    &lt;/body&gt;
    &lt;/html&gt;<i>
    </i>
    ``
    Copy linkTweet thisAlerts:
    @developer_webauthorJul 14.2020 — @DaveyErwin#1620482

    Thanks! :)
    ×

    Success!

    Help @developer_web spread the word by sharing this article on Twitter...

    Tweet This
    Sign in
    Forgot password?
    Sign in with TwitchSign in with GithubCreate Account
    about: ({
    version: 0.1.9 BETA 4.26,
    whats_new: community page,
    up_next: more Davinci•003 tasks,
    coming_soon: events calendar,
    social: @webDeveloperHQ
    });

    legal: ({
    terms: of use,
    privacy: policy
    });
    changelog: (
    version: 0.1.9,
    notes: added community page

    version: 0.1.8,
    notes: added Davinci•003

    version: 0.1.7,
    notes: upvote answers to bounties

    version: 0.1.6,
    notes: article editor refresh
    )...
    recent_tips: (
    tipper: @Yussuf4331,
    tipped: article
    amount: 1000 SATS,

    tipper: @darkwebsites540,
    tipped: article
    amount: 10 SATS,

    tipper: @Samric24,
    tipped: article
    amount: 1000 SATS,
    )...