HTMLSelect
returns an HTML select tag with the given set of options
returns an HTML select tag with the given set of options, mapping to the corresponding values
sets the default
DetailsDetails
- The HTML functions are contained in a package, MSP`HTML`, which is loaded as part of the webMathematica layout.
- The function HTMLSelect provides a useful way to generate select tags which browsers typically render as a drop-down menu, corresponding to Mathematica's PopupMenu.
- It is also possible to set selections by using the option SelectedOptions.
- HTMLSelect takes the following options.
-
SelectedValues initial selection based on values SelectedOptions initial selection based on options OptionAttributes attributes to apply to the HTML select tag
ExamplesExamplesopen allclose all
Basic Examples (1)Basic Examples (1)
You can demonstrate how the function works by installing and loading the package:
In[1]:= |
The function HTMLSelect provides a useful way to generate select tags with webMathematica. It takes a list of the different options and the name to be used when the selection is submitted. Its operation is shown below.
In[2]:= |
Out[2]= |
A typical browser will show this as a dropdown menu:
When an HTML form is submitted using this select, the variable $$arg1 will be set to the value of the selected option. In this example $arg1 will be set to 1 if "voltage" is selected, 2 if "current" is selected, and 3 if "resistance" is selected, according to the value assignments.
By default, the values for the option tags are chosen automatically as numbers from 1 to the number of options. It is also possible to set these with an argument.
In[3]:= |
Out[3]= |
It is also possible to set the initial selection by using the option SelectedOptions. Typically only one option is selected. In this example, the option labeled "b" will be selected.
In[4]:= |
Out[4]= |
The browser will show "b" initially selected:
Selecting the initial option by its value instead of its label can be done with the option SelectedValues.
In[5]:= |
Out[5]= |
If no values are given, the SelectedValues option can use the numerical values.
In[6]:= |
Out[6]= |
- Services
- Technical Consulting
- Corporate Consulting
- Company
- Events
- About Wolfram
- Careers
- Contact
- Connect
- Wolfram Community
- Wolfram Blog
- Newsletter