Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to default a dropdown to Blank

Status
Not open for further replies.

Weese

Programmer
Apr 3, 2003
17
I want a dropdown to be defaulted to blank initially.
After the user selects some value blank should go away.
This I am able to achieve in IE. But not in Mozilla or Netscape.

Please guide me .....
 
Is this what you need?

<select>
<option value=&quot;&quot; SELECTED>
<option value=&quot;1&quot;>One
</select>

Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rich Cook
 
hmm.. how about a blank option??
<select>
<option></option>

_________________________________________________________
$str = &quot;sleep is good for you. sleep gives you the energy you need to function&quot;;
$Nstr = ereg_replace(&quot;sleep&quot;,&quot;coffee&quot;,$str); echo $Nstr;

onpnt2.gif
[/sub]
 
This is not what my requirement.

There should not be any blank option.But it should be defaulted with blank.

eg. frm.cboSelect.value = &quot;&quot;;
sets it to blank without adding a new blank option.

This I have achieve in Mozilla / Netscape
 
hi Weese,

using [tt]frm.cboSelect.value = &quot;&quot;;[/tt] just isn't the correct way to do it. the fact that it defaults to a blank &quot;option&quot; in IE is most likely a quirk.

if you want an empty value to be presented initially in all browsers, you must have an empty <option></option>

if you can't live with that blank option in there after another option is selected, use script to remove it.





=========================================================
try { succeed(); } catch(E) { tryAgain(); }
-jeff
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top