form.html 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
  2. "http://www.w3.org/TR/html4/strict.dtd">
  3. <html>
  4. <head>
  5. <title>Dojo Form Widgets Test</title>
  6. <script type="text/javascript" src="../../dojo/dojo.js"
  7. djConfig="isDebug: false, parseOnLoad: true"></script>
  8. <script type="text/javascript">
  9. dojo.require("dijit.form.Form");
  10. dojo.require("dijit.form.ValidationTextBox");
  11. dojo.require("dijit.form.ComboBox");
  12. dojo.require("dijit.form.FilteringSelect");
  13. dojo.require("dijit.form.CheckBox");
  14. dojo.require("dijit.form.DateTextBox");
  15. dojo.require("dijit.form.CurrencyTextBox");
  16. dojo.require("dijit.form.NumberSpinner");
  17. dojo.require("dijit.form.Slider");
  18. dojo.require("dijit.form.Textarea");
  19. dojo.require("dijit.Editor");
  20. dojo.require("dijit.form.Button");
  21. dojo.require("dojo.data.ItemFileReadStore");
  22. dojo.require("dojo.parser"); // scan page for widgets and instantiate them
  23. // make dojo.toJson() print dates correctly (this feels a bit dirty)
  24. Date.prototype.json = function(){ return dojo.date.stamp.toISOString(this, {selector: 'date'});};
  25. </script>
  26. <style type="text/css">
  27. @import "../../dojo/resources/dojo.css";
  28. @import "../themes/tundra/tundra.css";
  29. @import "../themes/tundra/tundra_rtl.css";
  30. @import "../tests/css/dijitTests.css";
  31. .formQuestion {
  32. background-color:#d0e3f5;
  33. padding:0.3em;
  34. font-weight:900;
  35. font-family:Verdana, Arial, sans-serif;
  36. font-size:0.8em;
  37. color:#5a5a5a;
  38. }
  39. .formAnswer {
  40. background-color:#f5eede;
  41. padding:0.3em;
  42. margin-bottom:1em;
  43. width: 100%;
  44. }
  45. .pageSubContentTitle {
  46. color:#8e8e8e;
  47. font-size:1em;
  48. font-family:Verdana, Arial, sans-serif;
  49. margin-bottom:0.75em;
  50. }
  51. .small INPUT {
  52. width: 2.5em;
  53. }
  54. .medium INPUT {
  55. width: 10em;
  56. }
  57. .long INPUT {
  58. width: 20em;
  59. }
  60. .firstLabel {
  61. display: inline-block;
  62. display: -moz-inline-box;
  63. width: 10em;
  64. min-width: 10em;
  65. }
  66. .secondLabel {
  67. width: auto;
  68. margin-left: 5em;
  69. margin-right: 1em;
  70. }
  71. fieldset label {
  72. margin-right: 1em;
  73. }
  74. .noticeMessage {
  75. display: block;
  76. float: right;
  77. font-weight: normal;
  78. font-family:Arial, Verdana, sans-serif;
  79. color:#663;
  80. font-size:0.9em;
  81. }
  82. </style>
  83. </head>
  84. <body class="tundra">
  85. <div id="sunzhigang" dojoType="dojo.data.ItemFileReadStore" jsId="stateStore" url="../tests/_data/states.json">
  86. </div>
  87. <h2 class="pageSubContentTitle">Job Application Form</h2>
  88. <p>This is just a little demo of dijit's form widgets</p>
  89. <form dojoType="dijit.form.Form" id="myForm" action="showPost.php"
  90. execute="alert('Execute form w/values:\n'+dojo.toJson(arguments[0],true));">
  91. <div class="formQuestion">
  92. <span class="noticeMessage">
  93. As you type in the text below, notice how your input is auto
  94. corrected and also the auto completion on the state field.
  95. </span>
  96. <span>Name And Address</span>
  97. </div>
  98. <div class="formAnswer">
  99. <label class="firstLabel" for="name">Name *</label>
  100. <input type="text" id="name" name="name" class="medium"
  101. dojoType="dijit.form.ValidationTextBox"
  102. required="true"
  103. ucfirst="true"
  104. invalidMessage=""/>
  105. <br>
  106. <label class="firstLabel" for="address">Address *</label>
  107. <input type="text" id="address" name="address" class="long"
  108. dojoType="dijit.form.ValidationTextBox"
  109. required="true"
  110. trim="true"
  111. ucfirst="true" />
  112. <br>
  113. <label class="secondLabel" for="zip">Zip *</label>
  114. <input type="text" id="zip" name="zip" class="medium"
  115. dojoType="dijit.form.ValidationTextBox"
  116. trim="true"
  117. required="true"
  118. regExp="[0-9][0-9][0-9][0-9][0-9]"
  119. invalidMessage="5 digit zipcode (ex: 23245)"/>
  120. <br>
  121. <hr><!-- 上面是文本校验的信息设置-------------------------------------->
  122. <label class="firstLabel" for="city">City *</label>
  123. <select dojoType="dijit.form.ComboBox" name="city"
  124. value="New York"
  125. autocomplete="true"
  126. hasDownArrow="false">
  127. <option></option>
  128. <option value="1">Chicago</option>
  129. <option value="3">Los Angeles</option>
  130. <option value="4">New York</option>
  131. <option value="5">San Francisco</option>
  132. <option value="6">Seattle</option>
  133. </select>
  134. <p align="left"><label class="secondLabel" for="state">State</label>
  135. <input dojoType="dijit.form.FilteringSelect"
  136. store="stateStore" class="short" value="AR" id="state" name="state" />
  137. </p>
  138. <p>
  139. <label class="firstLabel" for="dob">DOB *</label>
  140. <input id="dob" name="dateOfBirth" dojoType="dijit.form.DateTextBox" required=true/>
  141. </p>
  142. <p>
  143. <select dojoType="dijit.form.FilteringSelect" name="country3" id="country3" autocomplete="false" value="CN">
  144. <option value="AU">Australia</option>
  145. <option value="CN" selected="selected"> China </option>
  146. <option value="JP" >Japan</option>
  147. <option value="USA" >USA</option>
  148. </select>
  149. <select dojoType="dijit.form.FilteringSelect"
  150. required="true" name="country4" id="country4" autocomplete="true">
  151. <option value="AU" selected="selected">Australia</option>
  152. <option value="CN"> China </option>
  153. <option value="JP" >Japan</option>
  154. <option value="USA" >USA</option>
  155. </select>
  156. </p>
  157. </div>
  158. <div class="formQuestion">
  159. <span class="noticeMessage">Custom checkboxes and radio buttons...</span>
  160. <span>Desired position</span>
  161. </div>
  162. <div class="formAnswer">
  163. <label class="firstLabel" for="position">Position</label>
  164. <fieldset id="position" class="dijitInline">
  165. <input type="checkBox" name="position" id="it" value="it" dojoType="dijit.form.CheckBox" />
  166. <label for="it">IT</label>
  167. <input type="checkBox" name="position" id="marketing" value="marketing" dojoType="dijit.form.CheckBox" />
  168. <label for="marketing">Marketing</label>
  169. <input type="checkBox" name="position" id="business" value="business" dojoType="dijit.form.CheckBox" />
  170. <label for="business" style="margin-right: 7em;">Business</label>
  171. </fieldset>
  172. <label class="secondLabel" for="hours">Hours</label>
  173. <fieldset id="hours" class="dijitInline">
  174. <input type="radio" name="hours" id="full" value="full" dojoType="dijit.form.RadioButton" />
  175. <label for="full">Full time</label>
  176. <input type="radio" name="hours" id="part" value="part" dojoType="dijit.form.RadioButton" />
  177. <label for="part">Part time</label>
  178. </fieldset>
  179. </div>
  180. <div class="formQuestion">
  181. <span class="noticeMessage">slider and spinner ...</span>
  182. <span>Education and Experience</span>
  183. </div>
  184. <div class="formAnswer">
  185. <table class="dijitReset">
  186. <tr>
  187. <td width="89">
  188. <label class="firstLabel" for="school">Education level</label></td>
  189. <td width="113" style="padding-left: 2em;">
  190. <span dojoType="dijit.form.HorizontalSlider" id="school" name="school"
  191. minimum="1"
  192. value="2"
  193. maximum="4"
  194. discreteValues="4"
  195. showButtons="false"
  196. style="width:200px; height: 40px;">
  197. <span dojoType="dijit.form.HorizontalRule" container="bottomDecoration" count=4
  198. style="height:5px;"></span>
  199. <ol dojoType="dijit.form.HorizontalRuleLabels" container="bottomDecoration"
  200. style="height:1em;font-size:75%;color:gray;">
  201. <li>high school</li>
  202. <li>college</li>
  203. <li>masters</li>
  204. <li>PhD</li>
  205. </ol>
  206. </span></td>
  207. <td width="276">
  208. <label class="secondLabel" for="experience">Work experience (years, 0-40)</label></td>
  209. <td width="331">
  210. <input dojotype="dijit.form.NumberSpinner"
  211. id="experience" name="experience"
  212. value="1"
  213. constraints="{min: 0, max:40, places:0}"
  214. size=10>
  215. </td>
  216. </tr>
  217. </table>
  218. </div>
  219. <div class="formQuestion">
  220. <span class="noticeMessage">Rich text editor that expands as you type in text</span>
  221. <label for="description">Self description</label>
  222. </div>
  223. <div class="formAnswer">
  224. <textarea dojoType="dijit.Editor" minHeight="5em" id="description" name="description">
  225. Write a brief summary of &lt;i&gt;your&lt;/i&gt; job skills... using &lt;b&gt;rich&lt;/b&gt; text.
  226. </textarea>
  227. </div>
  228. <div class="formQuestion">
  229. <span class="noticeMessage">Text area that expands as you type in text</span>
  230. <label for="references">References</label>
  231. </div>
  232. <div class="formAnswer">
  233. <textarea dojoType="dijit.form.Textarea" id="references" name="references">
  234. Write your references here (plain text)
  235. </textarea>
  236. </div>
  237. <center>
  238. <button dojoType="dijit.form.Button" iconClass="dijitEditorIcon dijitEditorIconSave" type=submit>
  239. OK
  240. </button>
  241. <button type="dijit.form.Button" onClick="javascript:alert(window.document.getElementById('sunzhigang').innerHTML);">
  242. 执行显示下拉选择
  243. </button>
  244. </center>
  245. </form>
  246. </body>
  247. </html>