htmlInputSelect
Drop-down selection list input class
[Previous] [Main] [Next]


Description
htmlInputSelect encapsulates the <INPUT TYPE="SELECT"></INPUT> tags. It is used to define a selection list control on a form, displaying a list of options from which the user can select an item. The htmlOption class is used internally to create the option list.  
 
Options may be added to the selection list using the Add() method or the << insertion operator.  
 
Options may also be stored in a text file, one option per line, and added as a group using the AddFile() method. Option values and display content may optionally be separated using a tab character.  
 
By default, the user will only be able to select a single option from the list. Use of the MultiSelect() method allows users to select multiple options from the list at a time. Usually, the user does this by holding down the shift key while clicking on each option. Non-adjacent options can usually be selected by holding down the Control key and clicking.  
 
The Size() method controls the display size of the selection list, letting you specifiy the number of options in the list that are displayed at one time. For multi-selection lists, the default behavior of most browsers is to display some (perhaps all) of the options. For single-selection lists, most browsers display the list as a single-line, drop-down menu.  
 
When the form containing the selection list is submitted to the server, a name/value pair is sent for each selected option in the list.  
 
Declaration
#include <dcmicro/htmlpp/select.h>  
 
Hierarchy
htmlinputselect.gif  
 
See Also
htmlForm, htmlOption  
 
Related Constants/Definitions
#define SINGLE_SELECT FALSE  
#define MULTI_SELECT TRUE  
 
Constructors
htmlInputSelect()  
Constructs an empty selection object.  
 
htmlInputSelect( const String& name, Boolean select_type = SINGLE_SELECT )  
Constructs an empty selection object, assigning it the specified name and setting the single/multiple selection capability.  
 
htmlInputSelect( const String& name,  
    short display_size,  
    Boolean select_type = SINGLE_SELECT )  
Constructs an empty selection object, assigning it the specified name, display_size, and setting the single/multiple selection capability.  
 
Destructor
virtual ~htmlInputSelect()  
Destroys the object.  
 
Member Methods
Add   htmlInputSelect& Add( const htmlOption& option )  
Adds the option object to the selection list and returns a reference to the list.  
 
Add   htmlInputSelect& Add( const String& text )  
Converts text string to an htmlOption object and add it to the selection list, then returns a reference to the list.  
 
AddFilehtmlInputSelect& AddFile( const String& filename,  
   int FAR * line_count = NULL )  
Add options from the text file filename. Each line in the file represents one option, must be less than 256 characters long, and must be followed by a newline '\n' character. Blank lines are ignored, and any leading or trailing spaces are removed. If the line contains a tab character, everything to the left of the tab will serve as the hidden value for the option while everything to the right will serve as the display content.  
 
line_count represents a pointer to a short variable that, if non-null, will be populated with the number of options added from the file.  
 
NamehtmlInputSelect& Name( const String& name )  
Sets the selection list control name to name, and returns a reference to the object.  
 
NameString Name() const  
Returns the selection list control name as a string, or an empty string if not set.  
 
Size   htmlInputSelect& Size( short display_size )  
Sets the number of options that are displayed in the selection list at one time to display_size, then returns a reference to the object. If display_size is zero, the size will default to the browser.  
 
Size   short Size() const  
Returns the number of options that are displayed in the selection list at one time, or zero if not set.  
 
MultiSelecthtmlInputSelect& MultiSelect( Boolean enable_multiple = TRUE )  
If enable_multiple is TRUE, the selection list will allow the user to select more than one option at a time. Otherwise, only a single option may be selected at a time. A reference to the object is returned.  
 
IsMultiSelect Boolean IsMultiSelect() const  
Returns TRUE if the selection list is set to allow multiple option selections at one time, FALSE if not.  
 
ClonehtmlObject FAR * Clone() const  
Returns a base-class pointer to a deep copy of the object.  
 
Print   void Print( ostream& os ) const  
Outputs the object to os.  
 
Example

See the example in Tutorial:Forms:Selection Lists  
 



©1998 DC Micro Development. All rights reserved.
No portion of this document may be c opied or reproduced without expressed written consent.
html++ is a trademark of DC Micro Development.