Wml-inputs

提供:Dev Guides
移動先:案内検索

WML-入力

WMLには、ユーザーがWAPアプリケーションを介して情報を入力できるさまざまなオプションがあります。

まず最初に、ユーザーがアイテムを直接選択できるようにするためのさまざまなオプションを見ていきます。 これらは通常、メニューとサブメニューの形式であり、ユーザーは必要なデータに正確にドリルダウンできます。

WML <select>要素:

<select> …​ </select> WML要素は選択リストの定義に使用され、<option> …​ </option>タグは選択リストのアイテムの定義に使用されます。 アイテムは、一部のWAPブラウザではラジオボタンとして表示されます。 <option> …​ </option>タグのペアは、<select> …​ </select>タグで囲む必要があります。

この要素は、次の属性をサポートしています。

Attribute Value Description
iname text Names the variable that is set with the index result of the selection
ivalue text Sets the pre-selected option element
multiple
  • true
Sets whether multiple items can be selected. Default is "false"
name text Names the variable that is set with the result of the selection
tabindex number Sets the tabbing position for the select element
title text Sets a title for the list
value text Sets the default value of the variable in the "name" attribute
xml:lang language_code Sets the language used in the element
class class data Sets a class name for the element.
id element ID A unique ID for the element.

以下は、これら2つの要素の使用法を示す例です。

<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.2//EN"
"http://www.wapforum.org/DTD/wml12.dtd">

<wml>

<card title="Selectable List">
<p> Select a Tutorial :
 <select>
  <option value="htm">HTML Tutorial</option>
  <option value="xml">XML Tutorial</option>
  <option value="wap">WAP Tutorial</option>
 </select>
</p>
</card>

</wml>

このプログラムをロードすると、次の画面が表示されます。

WAP例21

オプションを強調表示して入力すると、次の画面が表示されます。

WAP例22

複数のオプションを選択するオプションを提供し、次のように_multiple_属性を_true_に設定します。

<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.2//EN"
"http://www.wapforum.org/DTD/wml12.dtd">

<wml>

<card title="Selectable List">
<p> Select a Tutorial :
 <select multiple="true">
  <option value="htm">HTML Tutorial</option>
  <option value="xml">XML Tutorial</option>
  <option value="wap">WAP Tutorial</option>
 </select>
</p>
</card>

</wml>

これにより、次のように複数のオプションを選択する画面が表示されます。

WAP例24

WML <input>要素:

<input/>要素は入力フィールドを作成するために使用され、入力フィールドはユーザーから英数字データを取得するために使用されます。

この要素は、次の属性をサポートしています。

Attribute Value Description
name text The name of the variable that is set with the result of the user’s input
maxlength number Sets the maximum number of characters the user can enter in the field
emptyok
  • true *偽
Sets whether the user can leave the input field blank or not. Default is "false"
format A a N X x M m* f nf

Sets the data format for the input field. Default is "*M".

A =大文字のアルファベットまたは句読点文字a =小文字のアルファベットまたは句読点文字N =数字X =大文字x =小文字M =すべての文字m =すべての文字* f =任意の数の文字。 f_を上記の文字のいずれかに置き換えて、ユーザーが入力できる文字を指定します_nf = _n_を1〜9の数字に置き換えて、ユーザーが入力できる文字数を指定します。 _f_を上記のいずれかの文字に置き換えて、ユーザーが入力できる文字を指定します

size number Sets the width of the input field
tabindex number Sets the tabbing position for the select element
title text Sets a title for the list
type
  • text
  • パスワード
Indicates the type of the input field. The default value is "text". Password field is used to take password for authentication purpose.
value text Sets the default value of the variable in the "name" attribute
xml:lang language_code Sets the language used in the element
class class data Sets a class name for the element.
id element ID A unique ID for the element.

以下は、この要素の使用法を示す例です。

<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.2//EN"
"http://www.wapforum.org/DTD/wml12.dtd">

<wml>

<card title="Input Fields">
<p> Enter Following Information:<br/>
 Name: <input name="name" size="12"/>
 Age :  <input name="age" size="12" format="*N"/>
 Sex :  <input name="sex" size="12"/>
</p>
</card>

</wml>

これにより、必要な情報を入力するための次の画面が表示されます。

WAP例23

WML <fieldset>要素:

<fieldset/>要素は、さまざまな入力フィールドまたは選択可能なリストをグループ化するために使用されます。

この要素は、次の属性をサポートしています。

Attribute Value Description
title text Sets a title for the list
xml:lang language_code Sets the language used in the element
class class data Sets a class name for the element.
id element ID A unique ID for the element.

以下は、この要素の使用法を示す例です。

<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.2//EN"
"http://www.wapforum.org/DTD/wml12.dtd">

<wml>

<card title="Grouped Fields">
<p>
<fieldset title="Personal Info">
 Name: <input name="name" size="12"/>
 Age :  <input name="age" size="12" format="*N"/>
 Sex :  <input name="sex" size="12"/>
</fieldset>
</p>
</card>

</wml>

これにより、必要な情報を入力するための次の画面が表示されます。 この結果は、ブラウザごとに異なる場合があります。

WAP例25

WML <optgroup>要素

<optgroup/>要素は、選択可能なリスト内でさまざまなオプションをグループ化するために使用されます。

この要素は、次の属性をサポートしています。

Attribute Value Description
title text Sets a title for the list
xml:lang language_code Sets the language used in the element
class class data Sets a class name for the element.
id element ID A unique ID for the element.

以下は、この要素の使用法を示す例です。

<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.2//EN"
"http://www.wapforum.org/DTD/wml12.dtd">

<wml>

<card title="Selectable List">
<p>
 <select>
   <optgroup title="India">
    <option value="delhi">Delhi</option>
    <option value="mumbai">Mumbai</option>
    <option value="hyderabad">Hyderabad</option>
   </optgroup>
   <optgroup title="USA">
    <option value="ohio">Ohio</option>
    <option value="maryland">Maryland</option>
    <option value="washington">Washingtone</option>
   </optgroup>
 </select>
</p>
</card>

</wml>

ユーザーが上記のコードを読み込むと、2つのオプションが選択されます。

WAP例26

ユーザーがオプションのいずれかを選択すると、最終オプションが選択されるようになります。 したがって、ユーザーがインドを選択すると、選択する次のオプションが表示されます。

WAP例27