{jr_html_select}
The {jr_html_select} provides a convenient way to create HTML <select> drop-down list form elements, using data loaded from an external file as the <option> selections in the list. The {jr_html_select} template function first appeared in Jamroom 3.0.21.
Parameters:
Name |
Type |
Required |
Default |
Description |
name |
string |
yes |
n/a |
The "name" parameter tells the function what the HTML form name will be for the <select> list created. |
options |
string |
yes |
n/a |
The "options" parameter tells Jamroom the name of the file to use as the <options> (i.e. choices) in the created <select> element. The file MUST be located in the jamroom/config directory. See details on the file format below. |
selected |
string |
no |
n/a |
If the "selected" parameter is given, it will contain the item in the <option> list that will be pre-selected on form load. |
style |
string |
no |
width: 100%; |
The "style" option allows for CSS styling to override the default. |
Options Config File format:
The Options Config file that can be used by the {jr_html_select} template function must be in the proper "format" to be used by the function, so it knows the "value" to be used, as well as the "display" text. The basic format is:
value|display
The "value" (left side of pipe symbol) is what will be used as the "value" of the option element - i.e. this is what will actually be passed into the target form. The "display" part is what the user will see in the drop-down list as their choice for that value. Here's an example Options Config file with 5 entries (saved as "example.cfg" in the jamroom/config directory):
1|One
2|Two
3|Three
4|Four
5|Five |
And here's an example of the {jr_html_select} function to use this Options Config file:
{jr_html_select name="the_number" options="example.cfg" selected="2"} |
This would produce the following HTML code:
<select class="select" name="the_number" style="width: 100%;">
<option value="1">One</option>
<option value="2" selected="selected">Two</option>
<option value="3">Three</option>
<option value="4">Four</option>
<option value="5">Five</option>
</select> |
|