Jquery-mobile-form-structure

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

jQuery Mobile-フォーム構造

説明

ユーザー入力を収集するフォームレイアウトを作成するために使用されます。 <form> 要素には、HTTP POSTまたはGETを介して送信するactionおよびmethod属性を含める必要があります。 次のフォームコントロールを使用して、構造を作成できます。

  • テキスト入力
  • 入力を選択
  • チェックボックス入力
  • ラジオ入力
  • スライダー入力
  • 検索入力

次の例は、jQuery Mobileでのフォーム構造の使用を示しています。

<!DOCTYPE html>
<html>
   <head>
      <meta name = "viewport" content = "width = device-width, initial-scale = 1">
      <link rel = "stylesheet" href = "https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css">
      <script src = "https://code.jquery.com/jquery-1.11.3.min.js"></script>
      <script src = "https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>
   </head>

   <body>
      <div data-role = "page">
         <div data-role = "header">
            <h2>Form Structure</h2>
         </div>

         <div data-role = "main" class = "ui-content">
            <form method = "post" action="demo.php">
               <label for = "fname">Name</label>
                  <input type = "text" name = "fname" id = "fname"
                     placeholder = "Full Name">

               <label for = "date">Date</label>
               <input type = "date" name = "date" id = "date">

               <label for = "select">Select City</label>
               <select name = "select" id = "select">
                  <option value = "1">Belgaum</option>
                  <option value = "2">Pune</option>
                  <option value = "3">Chennai</option>
                  <option value = "4">Bangalore</option>
                  <option value = "5">Mumbai</option>
               </select>

               Flipswitch
               <input type = "checkbox" data-role = "flipswitch"><br/>

               Gender
               <label for = "radio1">
                  <input type = "radio" name = "radio-choice-0" id = "radio1">Male</input>
               </label>

               <label for = "radio2">
                  <input type = "radio" name = "radio-choice-0" id = "radio2">Female</input>
               </label>

               <label for = "radio3">
                  <input type = "radio" name = "radio-choice-0" id = "radio3">Other</input   >
               </label>

               Education Qualification
               <label for = "checkbox1">
                  <input type = "checkbox" id = "checkbox1">BE
               </label>

               <label for = "checkbox2">
                  <input type = "checkbox" id = "checkbox2">BCA
               </label>

               <label for = "checkbox3">
                  <input type = "checkbox" id = "checkbox3">BBA
               </label>

               <label for = "checkbox4">
                  <input type = "checkbox" id = "checkbox4">MBA
               </label>

               <label for = "checkbox5">
                  <input type = "checkbox" id = "checkbox5">MCA
               </label>
            </form>
         </div>
      </div>

   </body>
</html>

出力

上記のコードがどのように機能するかを確認するために、次の手順を実行してみましょう-

  • 上記のHTMLコードを form_structurel ファイルとしてサーバーのルートフォルダーに保存します。
  • このHTMLファイルをhttp://localhost/form_structurelとして開くと、次の出力が表示されます。