wood burning stoves 2.0*
The moose likes HTML, CSS and JavaScript and the fly likes How to make an item in a picklist unselectable ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "How to make an item in a picklist unselectable ?" Watch "How to make an item in a picklist unselectable ?" New topic
Author

How to make an item in a picklist unselectable ?

Frank Sikuluzu
Ranch Hand

Joined: Dec 16, 2003
Posts: 116
something looks simple but just no knowledge yet --

************
<FORM ACTION=".....">
.....
Month: <SELECT NAME="mon" SIZE="2">
<OPTION VALUE="00"> average
<OPTION VALUE="01"> January
<OPTION VALUE="06"> June
<OPTION VALUE="11"> Nov
<OPTION VALUE="12"> Dec

</SELECT>
....
</FORM>
************

I just want the first item "average" become

1) either it is NOT selectable
2) or if you select it and press SUBMIT button, it will be ignored in the "ACTION" (i.e. you won't be able to retrieve its value from the "mon" parameter). But other items won't be ignored if they are selected

between 1) and 2), I prefer 1). But if 1) is impossible, 2) is OK.

Please help.
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
You can not mkae it unselecteable, unless you run a script that validates the field stating that you need to select an option from the list. (Why include the option in the first place if it is not used?)

Eric

Why don't you just handle it on the server? Rather simple if statement in my eyes.

Eric
Frank Sikuluzu
Ranch Hand

Joined: Dec 16, 2003
Posts: 116
Originally posted by Eric Pascarello:
You can not mkae it unselecteable, unless you run a script that validates the field stating that you need to select an option from the list. (Why include the option in the first place if it is not used?)

Eric

Why don't you just handle it on the server? Rather simple if statement in my eyes.

Eric




Give you a concrete example :

I want to display a picklist like following

*************************
Deli Department
ham
cheese
potato
Seafood Department
rock fish
crab
lobster
*************************

But I only want users to pick the real item instead of "Seafood Department" or "deli dept" which is use to group the items. So, any idea we can handle from front ? I know it can be manipulated on server.
Andrew Eccleston
Ranch Hand

Joined: Jul 07, 2004
Posts: 140
Try the "optgroup" element. View the spec .

andrew


The statement below is true.<br />-------------------------------<br />The statement above is false.
Frank Sikuluzu
Ranch Hand

Joined: Dec 16, 2003
Posts: 116
Originally posted by Andrew Eccleston:
Try the "optgroup" element. View the spec .

andrew


This sounds like an excellent idea. In the following example --

**************
<OPTGROUP label="PortMaster 3">
<OPTION label="3.7.1" value="pm3_3.7.1">PortMaster 3 with ComOS 3.7.1</OPTION>
<OPTION label="3.7" value="pm3_3.7">PortMaster 3 with ComOS 3.7</OPTION>
<OPTION label="3.5" value="pm3_3.5">PortMaster 3 with ComOS 3.5</OPTION>
</OPTGROUP>
**************

Can I omit the "label=" for the <OPTION> tag ? I know "value" is useful for future information retrieval. Is "label" important ? Of course, it seems to be essential for <OPTGROUP>, but is it eseential for <OPTION> ?
Andrew Eccleston
Ranch Hand

Joined: Jul 07, 2004
Posts: 140
From what I see of your list, you should be able to omit the label in the OPTION tag. I think that the OPTION tag only needs the label attribute in more complicated lists. I personally have not had any problems with removing it.

andrew
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to make an item in a picklist unselectable ?
 
Similar Threads
jsp
problem getting all parameters from multiple select
textbox to listbox(simple)
html:option not selected
jsp and forms