Skip to content
Hub Nexus

No author yetClaim it

Version 1Updated 2 min read

Support

Motivation

You want to allow the user to select a single value from a list.

Method

Here is an example of using the select1 to create a drop-down list. The user must pick one and only one from the selected list.

Note that each item has a label (for humans to read) and a value (usually placed within an XML document). Values are typically stored in a database and use to compare to items together. Since values are frequently passed as arguments in a URL in a REST interface the convention is to only use lowercase letters and dashs. Do not put spaces, slashes and other characters in values if you are using REST interfaces. This makes the URLs difficult to read.

Screen Image

select1 control (Image: The original uploader was Dmccreary at English Wikibooks ., CC BY-SA 3.0)

Load XForms Application

Note that when the form is initially loaded, no day of the week is displayed in the input our output. After you press the drop-down list (the back triangle to the right of the input control) and select a day of the week the value will be filled in. A label (the name that starts with the uppercase) will be displayed in the select1 control. The actual version in the model will be the value which is the lower-case version. This is also the version that is displayed in the output.

Source Code

xmlns="http://www.w3.org/1999/xhtml"
xmlns:xf="http://www.w3.org/2002/xforms">

Demonstration of XForms Select1
type="text/css">

xmlns="">

ref="DayOfWeekCode">
Day of Week:

Monday
monday

Tuesday
tuesday

Wednesday
wednesday

Thursday
thursday

Friday
friday

Saturday
saturday

Sunday
sunday

Output: ref="DayOfWeekCode"/>

Discussion

The list of values does not have to be in the body of the form. It can be in the model stored in an instance, it can be fetched on-demand from a web service. We will cover these in other examples.

Where this page came from

This page was imported from Wikibooks. From “XForms” on Wikibooks, by its contributors, under CC BY-SA 4.0. Changed here: set as a page; navigation and edit links left out; each image under its own licence, credited in its caption.

Nobody has written it yet — it is the source material at a new address, which is why search engines are asked to skip it and why no one earns from it. It is up for grabs: take it on, and it is yours to rewrite and to earn from.

Get each new page of

XForms

Following means one email when a page is added, nothing when a page changes.

Following means one email when a page is added, nothing when a page changes.

Comments

Spinner Logo

Next in XForms

CC BY-SA 4.0
One challenge of using this control is to let the user know they can enter an exception. You may have to add instructional text on the form such as "type value in this field if it does not appear on this list".
CC BY-SA 4.0
Note that in this program we use appearance="full" attribute. ## XForms Application [Load XForms Application]( Note that as you select multiple items a space-delimited list of items appears in the output. This is a good example of why you do not want to put any spaces in a selection item **value** t
CC BY-SA 4.0
Make sure to put the page into edit mode if you want to copy and paste the code. This is because Wiki software replaces the ampersand-lt-semicolon with a "&". xmlns=" xmlns:xf=" xmlns:xs=" xmlns:ev=" Select County type="text/css"> @namespace xf url(" body { font-family: Helvetica, sans-serif; font-s
CC BY-SA 4.0
XForms, Select1 Multi-Column
CC BY-SA 4.0
xmlns=" xmlns:xf=" Getting Selection List Data From the XForms Model type="text/css"> body {font-family: Helvetica, Verdanan, sans-serif;} ]]> id="my-item" xmlns=""> red id="code-tables" xmlns=""> ItemColorCode Red red Orange orange Yellow yellow Green green Blue blue Getting Selection List Data Fro
CC BY-SA 4.0
In this example the file that contains the codes is just a well-formed XML file in the same directory that the form is located in. ## Loading XML instance data from a local file or web service The following code fragment, usually in the HTML head, demonstrates how to read XML data from a local file