form.html 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. <!DOCTYPE HTML>
  2. <html>
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  6. <title>Example page for HTML form handling</title>
  7. </head>
  8. <body>
  9. <!-- HTML forms can use GET or POST, and the encoding can be application/x-www-form-urlencoded or multipart/form-data.
  10. If no method is specified (like <form method="method">), GET should be the default method.
  11. If no encoding is specified, application/x-www-form-urlencoded should be the default.
  12. Submit buttons may overwrite action, method and enctype by using formaction, formmethod and formenctype.
  13. References:
  14. http://www.w3.org/TR/html401/interact/forms.html
  15. http://www.w3schools.com/html/html_forms.asp,
  16. http://www.w3schools.com/html/html_form_attributes.asp
  17. http://www.w3.org/TR/html401/interact/forms.html#adef-enctype
  18. -->
  19. <form action="/handle_form.embedded_c.example.callback">
  20. See <a href="http://www.w3schools.com/html/html_form_input_types.asp">HTML form tutorial</a>
  21. and <a href="http://www.w3.org/TR/html401/interact/forms.html">HTML spec</a>.<br />
  22. <fieldset>
  23. <legend>Text inputs:</legend>
  24. A text: <input type="text" name="textin"><br />
  25. A password: <input type="password" name="passwordin"><br />
  26. </fieldset>
  27. <fieldset>
  28. <legend>Radio set 1:</legend>
  29. <input type="radio" name="radio1" value="val1" checked>val1<br />
  30. <input type="radio" name="radio1" value="val2">val2<br />
  31. <input type="radio" name="radio1" value="val3">val3<br />
  32. </fieldset>
  33. <fieldset>
  34. <legend>Radio set 2:</legend>
  35. <input type="radio" name="radio2" value="val1" checked>val1<br />
  36. <input type="radio" name="radio2" value="val2">val2<br />
  37. <input type="radio" name="radio2" value="val3">val3<br />
  38. </fieldset>
  39. <fieldset>
  40. <legend>Checkboxes:</legend>
  41. <input type="checkbox" name="check1" value="val1" checked>val1<br />
  42. <input type="checkbox" name="check2" value="val2">val2<br />
  43. <input type="checkbox" name="check3" value="val3">val3<br />
  44. </fieldset>
  45. <fieldset>
  46. <legend>HTML5 inputs:</legend>
  47. A number: <input type="number" name="numberin" min="1" max="5"><br />
  48. A date: <input type="date" name="datein"><br />
  49. A color: <input type="color" name="colorin"><br />
  50. A range: <input type="range" name="rangein" min="1" max="5"><br />
  51. A month: <input type="month" name="monthin"><br />
  52. A week: <input type="week" name="weekin"><br />
  53. A time: <input type="time" name="timein"><br />
  54. A datetime: <input type="datetime" name="datetimen"><br />
  55. A datetime-local: <input type="datetime-local" name="datetimelocalin"><br />
  56. An email: <input type="email" name="emailin"><br />
  57. A search: <input type="search" name="searchin"><br />
  58. A tel: <input type="tel" name="telin"><br />
  59. An url: <input type="url" name="urlin"><br />
  60. </fieldset>
  61. <fieldset>
  62. <legend>Files:</legend>
  63. A file: <input type="file" name="filein"><br />
  64. Multiple files: <input type="file" name="filesin" multiple><br>
  65. </fieldset>
  66. <fieldset>
  67. <legend>Dropdown:</legend>
  68. <select name="selectin">
  69. <option value="opt1">opt1</option>
  70. <option value="opt2">opt2</option>
  71. <option value="opt3">opt3</option>
  72. </select>
  73. </fieldset>
  74. <fieldset>
  75. <legend>Text area:</legend>
  76. <textarea name="message" rows="10" cols="30">Text area default text.</textarea>
  77. </fieldset>
  78. <fieldset>
  79. <legend>Submit:</legend>
  80. <fieldset>
  81. <legend>Submit to Lua script:</legend>
  82. This will only work if server side Lua scripting is activated and /handle_form.lua can be found on the server.
  83. <br>
  84. <input type="submit" value="Submit" formmethod="POST" formenctype="multipart/form-data"
  85. formaction="/handle_form.lua">
  86. </fieldset>
  87. <fieldset>
  88. <legend>Submit to callback:</legend>
  89. This will work in the embedded_c example. It will call mg_handle_form_data to parse the request.
  90. <br>
  91. <input type="submit" value="Submit (form default)">
  92. <input type="submit" value="Submit (GET)" formmethod="GET">
  93. <input type="submit" value="Submit (POST)" formmethod="POST">
  94. <input type="submit" value="Submit (POST, url-encoded)" formmethod="POST" formenctype="application/x-www-form-urlencoded">
  95. <input type="submit" value="Submit (POST, form-data)" formmethod="POST" formenctype="multipart/form-data">
  96. </fieldset>
  97. </fieldset>
  98. </form>
  99. </body>
  100. </html>