Tizen 2.1 base
[platform/framework/web/web-ui-fw.git] / libs / js / jquery-mobile-1.0.1pre / docs / forms / checkboxes / index.html
1 <!DOCTYPE html> 
2 <html> 
3         <head>
4         <meta charset="utf-8">
5         <meta name="viewport" content="width=device-width, initial-scale=1"> 
6         <title>jQuery Mobile Docs - Checkboxes</title> 
7         <link rel="stylesheet"  href="../../../css/themes/default/" />  
8         <link rel="stylesheet" href="../../_assets/css/jqm-docs.css"/>
9         <script src="../../../js/jquery.js"></script>
10         <script src="../../../experiments/themeswitcher/jquery.mobile.themeswitcher.js"></script>
11         <script src="../../_assets/js/jqm-docs.js"></script>
12         <script src="../../../js/"></script>
13 </head> 
14 <body> 
15
16         <div data-role="page" class="type-interior">
17
18                 <div data-role="header" data-theme="f">
19                 <h1>Checkboxes</h1>
20                 <a href="../../../" data-icon="home" data-iconpos="notext" data-direction="reverse" class="ui-btn-right jqm-home">Home</a>
21         </div><!-- /header -->
22
23         <div data-role="content">
24                 <div class="content-primary">
25                 
26                 <form action="#" method="get">
27
28                 <h2>Checkboxes</h2>
29
30     <ul data-role="controlgroup" data-type="horizontal" class="localnav">
31       <li><a href="index.html" data-role="button" data-transition="fade" class="ui-btn-active">Basics</a></li>
32       <li><a href="options.html" data-role="button" data-transition="fade">Options</a></li>
33       <li><a href="methods.html" data-role="button" data-transition="fade">Methods</a></li>
34       <li><a href="events.html" data-role="button" data-transition="fade">Events</a></li>
35     </ul>
36
37                 <p>Checkboxes are used to provide a list of options where more than one can be selected. Traditional desktop checkboxes are not optimized for touch input so in jQuery Mobile, we style the <code>label</code> for the checkboxes so they are larger and look clickable. A custom set of icons are added to the label to provide additional visual feedback.</p>
38                 
39                 <p>Both the radio and checkbox controls below use standard input/label markup, but are styled to be more touch-friendly. The styled control you see is actually the label element, which sits over the real input, so if images fail to load, you'll still have a functional control. In most browsers, clicking the label automatically triggers a click on the input, but we've had to trigger the update manually for a few mobile browsers that don't do this natively. On the desktop, these controls are keyboard and screen-reader accessible. View the <a href="../../api/data-attributes.html">data- attribute reference</a> to see all the possible attributes you can add to checkboxes.</p>
40
41                 <p>To create a single checkbox, add an <code>input</code> with a <code>type="checkbox"</code> attribute and a corresponding <code>label</code>. Set the <code>for</code> attribute of the <code>label</code> to match the ID of the <code>input</code> so they are semantically associated.</p>
42                 
43                 <pre><code>     
44 &lt;input type=&quot;checkbox&quot; name=&quot;checkbox-1&quot; id=&quot;checkbox-0&quot; class=&quot;custom&quot; /&gt;
45 &lt;label for=&quot;checkbox-0&quot;&gt;I agree&lt;/label&gt;
46                 </code></pre>
47                 
48                 <p>This will produce a basic checkbox. The default styles will set the width of the element to 100% of the parent container.</p>
49                                         
50                 <input type="checkbox" name="checkbox-0" id="checkbox-0" class="custom" />
51                 <label for="checkbox-0">I agree</label>
52                                         
53
54                         
55                 <p>Because checkboxes use the <code>label</code> element for the text displayed next to the checkbox form element, we recommend wrapping the checkbox in a <code>fieldset</code> element that has a <code>legend</code> which acts as the title for the question. Add the  <code> data-role="controlgroup"</code> attribute to the <code>fieldset</code> so it can be styled in a parallel way as text inputs, selects or other form elements.</p>
56                 
57                 <p>Lastly, need to wrap the <code>fieldset</code> in a <code>div</code> with <code> data-role="controlgroup"</code> attribute to the <code>fieldset</code> so it can be styled in a parallel way as text inputs, selects or other form elements.</p>
58
59
60 <pre><code>     
61 &lt;div data-role=&quot;fieldcontain&quot;&gt;
62     <strong>&lt;fieldset data-role=&quot;controlgroup&quot;&gt;
63            &lt;legend&gt;Agree to the terms:&lt;/legend&gt;</strong>
64            &lt;input type=&quot;checkbox&quot; name=&quot;checkbox-1&quot; id=&quot;checkbox-1&quot; class=&quot;custom&quot; /&gt;
65            &lt;label for=&quot;checkbox-1&quot;&gt;I agree&lt;/label&gt;
66     <strong>&lt;/fieldset&gt;</strong>
67 &lt;/div&gt;
68 </code></pre>
69
70         <div data-role="fieldcontain">
71                 <fieldset data-role="controlgroup">
72                         <legend>Agree to the terms:</legend>
73                         <input type="checkbox" name="checkbox-1" id="checkbox-1" class="custom" />
74                         <label for="checkbox-1">I agree</label>
75             </fieldset>
76         </div>
77                 
78                 <h2>Vertically grouped checkboxes</h2>
79                 
80                 <p>Typically, there are multiple checkboxes listed under a question title. To visually integrate multiple checkboxes into a grouped button set, the framework will automatically remove all margins between buttons and round only the top and bottom corners of the set if there is a <code> data-role="controlgroup"</code> attribute on the fie.</p>
81
82                         <div  data-role="fieldcontain">
83                                 <fieldset data-role="controlgroup">
84                                         <legend>Choose as many snacks as you'd like:</legend>
85                                         <input type="checkbox" name="checkbox-1a" id="checkbox-1a" class="custom" />
86                                         <label for="checkbox-1a">Cheetos</label>
87
88                                         <input type="checkbox" name="checkbox-2a" id="checkbox-2a" class="custom" />
89                                         <label for="checkbox-2a">Doritos</label>
90                                         
91                                         <input type="checkbox" name="checkbox-3a" id="checkbox-3a" class="custom" />
92                                         <label for="checkbox-3a">Fritos</label>
93
94                                         <input type="checkbox" name="checkbox-4a" id="checkbox-4a" class="custom" />
95                                         <label for="checkbox-4a">Sun Chips</label>
96                             </fieldset>
97                         </div>
98                 
99                 <h2>Horizontal toggle sets</h2>
100                 
101                 <p>Checkboxes can also be used for grouped button sets where more than one button can be selected at once, such as the bold, italic and underline button group seen in word processors. To make a horizontal button set, add the <code> data-type="horizontal"</code> to the <code>fieldset</code>.</p>
102
103 <code>
104 &lt;fieldset data-role=&quot;controlgroup&quot; <strong>data-type=&quot;horizontal&quot;</strong>&gt;
105 </code>
106
107                         <p>The framework will float the labels so they sit side-by-side on a line, hide the checkbox icons and only round the left and right edges of the group.</p>
108                         
109                 <div data-role="fieldcontain">
110                     <fieldset data-role="controlgroup" data-type="horizontal">
111                         <legend>Font styling:</legend>
112                         <input type="checkbox" name="checkbox-6" id="checkbox-6" class="custom" />
113                                 <label for="checkbox-6">b</label>
114
115                                 <input type="checkbox" name="checkbox-7" id="checkbox-7" class="custom" />
116                                 <label for="checkbox-7"><em>i</em></label>
117
118                                 <input type="checkbox" name="checkbox-8" id="checkbox-8" class="custom" />
119                                 <label for="checkbox-8">u</label>    
120                     </fieldset>
121                 </div>
122
123
124
125
126         </form>
127         
128         </div><!--/content-primary -->          
129         
130         <div class="content-secondary">
131                 
132                 <div data-role="collapsible" data-collapsed="true" data-theme="b" data-content-theme="d">
133                         
134                                 <h3>More in this section</h3>
135                                 
136                                 <ul data-role="listview" data-theme="c" data-dividertheme="d">
137                                 
138                                         <li data-role="list-divider">Form elements</li>
139                                         <li><a href="../docs-forms.html">Form basics</a></li>
140                                         <li><a href="../forms-all.html">Form element gallery</a></li>
141                                         <li><a href="../textinputs/index.html">Text inputs</a></li>
142                                         <li><a href="../search/">Search input</a></li>
143                                         <li><a href="../slider/">Slider</a></li>
144                                         <li><a href="../switch/">Flip toggle switch</a></li>
145                                         <li><a href="../radiobuttons/">Radio buttons</a></li>
146                                         <li data-theme="a"><a href="index.html">Checkboxes</a></li>
147                                         <li><a href="../selects/">Select menus</a></li>
148                                         <li><a href="../forms-themes.html">Theming forms</a></li>
149                                         <li><a href="../forms-all-native.html">Native form elements</a></li>
150                                         <li><a href="../forms-sample.html">Submitting forms</a></li>
151                                         
152         
153                                 </ul>
154                 </div>
155         </div>          
156
157 </div><!-- /content -->
158
159 <div data-role="footer" class="footer-docs" data-theme="c">
160                 <p>&copy; 2011 The jQuery Project</p>
161 </div>
162         
163 </div><!-- /page -->
164
165 </body>
166 </html>