HTML Form Option Element

About...


The Option element provides choices...

Choices

Using Option, we can constrain a list of items to narrow the data entered in the field... if the data is constrainable.

The Option element employes the value attribute which carries the data to be submitted with the form.

Therefore, using Option, we can display one thing and submit a different value.

There is a catch though... Option can only be used inside of a Select OR DataList element... at least if you want it to work. You can put an option tag outside these elements but it would look like this:

Try clicking on them... see what I mean?

CREATED 2020-12-14 11:58:57.0

010-00-04-9C

UPDATED 2020-12-14 11:59:18.0

Example...


A list of states in The United States:

Select a State:

With Option, we can show the state name... but... submit the state two letter postal code with the form. Try it!

CREATED 2020-12-14 12:18:42.0

010-00-04-9D

UPDATED 2020-12-14 12:18:54.0

Attributes...


In addition to the HTML global attributes... Option employes these attributes as well:

Name Values Description
disabled disabled Disables the option
label text The label for the option
selected selected Used with the option that should already be selected
value text The data sent with the form... for the selected option

Option also supports the global HTML events.

CREATED 2020-12-14 12:39:35.0

010-00-04-9E

UPDATED 2020-12-14 12:39:47.0

Knowledge

L
I
N
K
S

DBID: db.wam

Page Server: Ruger

©2012 Leistware Data Systems

      Hello anonymous