Help - Search - Members - Calendar
Full Version: Hiding options in drop down boxes
HTMLHelp Forums > Web Authoring > Markup (HTML, XHTML, XML)
code2319
Good morning from Missouri!!!

I just signed up with HTMLHelp.com this morning after battling a coding issue for an hour. I am trying to group like terms in a drop down box and separate them using '---------------' values. Here's an example of what the drop down box would look like:

Database
Table
View
-----------------
Element
File
Record
IDMS
-----------------
Program
Copybook

Using HTML, can you mask the '--------------------' values so that they are not clickable for selection? So that they are for display purposes only? Here's my code:

<table>
<form method="post" action="resultsMetaData.do" name="form1" onSubmit="showProcessing();">
<tr>
<td align=center><label for="searchtype">Search Type</label></td>
<td align=center><label for="searchterm">Search Term</label></td></tr>
<tr>
<td><SELECT NAME="searchtype">
<OPTION>Database</OPTION>
<OPTION>Table</OPTION>
<OPTION>View</OPTION>
<OPTION>---------------</OPTION>
<OPTION>Element</OPTION>
<OPTION>File</OPTION>
<OPTION>Record</OPTION>
<OPTION>IDMS</OPTION>
<OPTION>---------------</OPTION>
<OPTION>Program</OPTION>
<OPTION>Copybook</OPTION>
<OPTION>Record Copybook</OPTION>
<OPTION>---------------</OPTION>
<OPTION>Glossary</OPTION>
</SELECT></td>
<td><input type="text" name="searchterm" size="20" maxlength="255" value="" />
</td>
<td><input type="submit" name="submit1" value="Search"></td>
</tr>
</form>
</table>

Any help would be appreciated! I'm looking through manuals now also. And we all know how exciting that can be.... HA!
Sparkyg
Hi There

Within the showProcessing() function you need to check the value of searchtype, and return false if it is equal to '---------', that then stops the form being submitted

cheers

Sparky
Christian J
QUOTE
Using HTML, can you mask the '--------------------' values so that they are not clickable for selection? So that they are for display purposes only?


With HTML you might use the OPTION element's DISABLED attribute, but IE doesn't support it.

Javascript might be used as a workaround, but make sure the server-side script works even if a user without javascript submits "-----------------".
Brian Chandler
QUOTE(code2319 @ Sep 29 2006, 11:18 PM) *

Good morning from Missouri!!!

I just signed up with HTMLHelp.com this morning after battling a coding issue for an hour. I am trying to group like terms in a drop down box and separate them using '---------------' values. Here's an example of what the drop down box would look like:

Database
Table
View
-----------------
Element
File
Record
IDMS
-----------------
Program
Copybook

Using HTML, can you mask the '--------------------' values so that they are not clickable for selection? So that they are for display purposes only? Here's my code:

<table>
<form method="post" action="resultsMetaData.do" name="form1" onSubmit="showProcessing();">
<tr>
<td align=center><label for="searchtype">Search Type</label></td>
<td align=center><label for="searchterm">Search Term</label></td></tr>
<tr>
<td><SELECT NAME="searchtype">
<OPTION>Database</OPTION>
<OPTION>Table</OPTION>
<OPTION>View</OPTION>
<OPTION>---------------</OPTION>
<OPTION>Element</OPTION>
<OPTION>File</OPTION>
<OPTION>Record</OPTION>
<OPTION>IDMS</OPTION>
<OPTION>---------------</OPTION>
<OPTION>Program</OPTION>
<OPTION>Copybook</OPTION>
<OPTION>Record Copybook</OPTION>
<OPTION>---------------</OPTION>
<OPTION>Glossary</OPTION>
</SELECT></td>
<td><input type="text" name="searchterm" size="20" maxlength="255" value="" />
</td>
<td><input type="submit" name="submit1" value="Search"></td>
</tr>
</form>
</table>

Any help would be appreciated! I'm looking through manuals now also. And we all know how exciting that can be.... HA!


Another Really Simple answer might be to separate them by *blank* entries. The blank will probably be ignored naturally if your script is reasonably robust. Well, this won't work if you _require_ the input.


pandy
You could use OPTGROUP and its LABEL attribute. It may or may not be possible to style the label in different browsers.
http://www.htmlhelp.com/reference/html40/forms/optgroup.html
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2009 Invision Power Services, Inc.