Wrox Programmer Forums
|
HTML Code Clinic Do you have some HTML code you'd like to share and get suggestions from others for tweaking or improving it? This discussion is the place.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the HTML Code Clinic section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 7th, 2003, 08:14 AM
Authorized User
 
Join Date: Jun 2003
Posts: 78
Thanks: 0
Thanked 0 Times in 0 Posts
Default DropDown default value

I have a this dropdown list:
<select name="Title" size="1" style="width=250px;">
    <option value=1>Mr</option>
    <option value=2>Mrs</option>
    <option value=3>Miss</option>
    <option value=4>Ms</option>
    <option value=5>Dr</option>
</select>

Is it possible to have default value to no selection (none of the item of the list)?
If not, is there a way to simulate this behavior?

Stéphane Lajoie
__________________
Stéphane

A programmer is a device that transform coffee in code lines

\"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.\" Rich Cook
 
Old August 7th, 2003, 01:13 PM
Registered User
 
Join Date: Jun 2003
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi
There isn't a way to have no value selected, even if you don't set any as selected, like you have done.
The usual way to get round this is to put in a sort of "dummy" option at the top of the list, which you can check for when your form is submitted, or whatever you want to do with it.
So in your example, you could make it something like:

<select name="Title" size="1" style="width=250px;">
    <option value=0>Choose title..</option>
    <option value=1>Mr</option>
    <option value=2>Mrs</option>
    <option value=3>Miss</option>
    <option value=4>Ms</option>
    <option value=5>Dr</option>
</select>

So when you check, if the value is 0, you know they did not select anything.


Regards
Philip
-------------------------
[email protected]





Similar Threads
Thread Thread Starter Forum Replies Last Post
Dropdown list maha .NET Framework 2.0 7 April 28th, 2007 12:32 AM
DropDown in DataGrid kiranpanjala Classic ASP Databases 0 January 24th, 2005 10:54 AM
Help on DropDown object...? rstober Excel VBA 2 September 16th, 2003 10:31 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.