{"id":250330,"date":"2022-08-23T10:43:11","date_gmt":"2022-08-23T02:43:11","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=250330"},"modified":"2022-08-21T18:43:52","modified_gmt":"2022-08-21T10:43:52","slug":"forms-and-inputs","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/forms-and-inputs.html","title":{"rendered":"HTML \u8868\u5355\u548c\u8f93\u5165\u7b80\u4ecb"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\nHTML \u8868\u5355\u7528\u4e8e\u6536\u96c6\u7528\u6237\u7684\u8f93\u5165\u4fe1\u606f\u3002HTML \u8868\u5355\u8868\u793a\u6587\u6863\u4e2d\u7684\u4e00\u4e2a\u533a\u57df\uff0c\u6b64\u533a\u57df\u5305\u542b\u4ea4\u4e92\u63a7\u4ef6\uff0c\u5c06\u7528\u6237\u6536\u96c6\u5230\u7684\u4fe1\u606f\u53d1\u9001\u5230 Web \u670d\u52a1\u5668\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n
\u5728\u7ebf\u5b9e\u4f8b<\/strong><\/div>\n

\u5b9e\u4f8b<\/strong>
\n\u4ee5\u4e0b\u5b9e\u4f8b\u521b\u5efa\u4e86\u4e00\u4e2a\u8868\u5355\uff0c\u5305\u542b\u4e24\u4e2a\u8f93\u5165\u6846\uff1a<\/p>\n

<form<\/span> action<\/span>=<\/span>\"\"<\/span>>\r\nFirst name: <input<\/span> type<\/span>=<\/span>\"text\"<\/span> name<\/span>=<\/span>\"firstname\"<\/span>><br<\/span>>\r\nLast name: <input<\/span> type<\/span>=<\/span>\"text\"<\/span> name<\/span>=<\/span>\"lastname\"<\/span>>\r\n<\/<\/span>form<\/span>><\/span><\/span><\/span><\/span><\/pre>\n

\u5b9e\u4f8b<\/strong>
\n\u4ee5\u4e0b\u5b9e\u4f8b\u521b\u5efa\u4e86\u4e00\u4e2a\u8868\u5355\uff0c\u5305\u542b\u4e00\u4e2a\u666e\u901a\u8f93\u5165\u6846\u548c\u4e00\u4e2a\u79d8\u5bc6\u8f93\u5165\u6846\uff1a<\/p>\n

<form<\/span> action<\/span>=<\/span>\"\"<\/span>>\r\nUsername: <input<\/span> type<\/span>=<\/span>\"text\"<\/span> name<\/span>=<\/span>\"user\"<\/span>><br<\/span>>\r\nPassword: <input<\/span> type<\/span>=<\/span>\"password\"<\/span> name<\/span>=<\/span>\"password\"<\/span>><\/span>
\r\n<\/form<\/span>><\/span><\/span><\/span><\/span><\/pre>\n
HTML \u8868\u5355<\/strong><\/div>\n

\u8868\u5355\u662f\u4e00\u4e2a\u5305\u542b\u8868\u5355\u5143\u7d20\u7684\u533a\u57df\u3002<\/p>\n

\u8868\u5355\u5143\u7d20\u662f\u5141\u8bb8\u7528\u6237\u5728\u8868\u5355\u4e2d\u8f93\u5165\u5185\u5bb9\uff0c\u6bd4\u5982\uff1a\u6587\u672c\u57df\uff08textarea\uff09\u3001\u4e0b\u62c9\u5217\u8868\uff08select\uff09\u3001\u5355\u9009\u6846\uff08radio-buttons\uff09\u3001\u590d\u9009\u6846\uff08checkbox\uff09 \u7b49\u7b49\u3002
\n\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528<form>\u6807\u7b7e\u6765\u521b\u5efa\u8868\u5355:
\n\u5b9e\u4f8b<\/strong><\/p>\n

<form<\/span>>\r\n.\r\ninput \u5143\u7d20\r\n.\r\n<\/<\/span>form<\/span>><\/span><\/span><\/pre>\n
HTML \u8868\u5355 - \u8f93\u5165\u5143\u7d20<\/strong><\/div>\n

\u591a\u6570\u60c5\u51b5\u4e0b\u88ab\u7528\u5230\u7684\u8868\u5355\u6807\u7b7e\u662f\u8f93\u5165\u6807\u7b7e <input>\u3002<\/p>\n

\u8f93\u5165\u7c7b\u578b\u662f\u7531 type \u5c5e\u6027\u5b9a\u4e49\u3002<\/p>\n

\u63a5\u4e0b\u6765\u6211\u4eec\u4ecb\u7ecd\u51e0\u79cd\u5e38\u7528\u7684\u8f93\u5165\u7c7b\u578b\u3002<\/p>\n

\u6587\u672c\u57df\uff08Text Fields\uff09<\/strong><\/div>\n

\u6587\u672c\u57df\u901a\u8fc7 <input type=\"text\"> \u6807\u7b7e\u6765\u8bbe\u5b9a\uff0c\u5f53\u7528\u6237\u8981\u5728\u8868\u5355\u4e2d\u952e\u5165\u5b57\u6bcd\u3001\u6570\u5b57\u7b49\u5185\u5bb9\u65f6\uff0c\u5c31\u4f1a\u7528\u5230\u6587\u672c\u57df\u3002<\/p>\n

\u5b9e\u4f8b<\/strong><\/p>\n

<form<\/span>>\r\nFirst name: <input<\/span> type<\/span>=<\/span>\"text\"<\/span> name<\/span>=<\/span>\"firstname\"<\/span>><br<\/span>>\r\nLast name: <input<\/span> type<\/span>=<\/span>\"text\"<\/span> name<\/span>=<\/span>\"lastname\"<\/span>>\r\n<\/<\/span>form<\/span>><\/span><\/span><\/span><\/span><\/pre>\n

\u6d4f\u89c8\u5668\u663e\u793a\u5982\u4e0b\uff1a<\/p>\n

\nFirst name:
\nLast name:
\n<\/form>\n

\u6ce8\u610f:\u8868\u5355\u672c\u8eab\u5e76\u4e0d\u53ef\u89c1\u3002\u540c\u65f6\uff0c\u5728\u5927\u591a\u6570\u6d4f\u89c8\u5668\u4e2d\uff0c\u6587\u672c\u57df\u7684\u9ed8\u8ba4\u5bbd\u5ea6\u662f 20 \u4e2a\u5b57\u7b26\u3002<\/p>\n

\u5bc6\u7801\u5b57\u6bb5<\/strong><\/div>\n

\u5bc6\u7801\u5b57\u6bb5\u901a\u8fc7\u6807\u7b7e <input type=\"password\">\u6765\u5b9a\u4e49:<\/p>\n

\u5b9e\u4f8b<\/strong><\/p>\n

\r\n<form<\/span>>\r\nPassword: <input<\/span> type<\/span>=<\/span>\"password\"<\/span> name<\/span>=<\/span>\"pwd\"<\/span>>\r\n<\/<\/span>form<\/span>><\/span><\/span><\/span><\/pre>\n

\u6d4f\u89c8\u5668\u663e\u793a\u6548\u679c\u5982\u4e0b:<\/p>\n\nPassword:
\n<\/form>\n

\u6ce8\u610f\uff1a\u5bc6\u7801\u5b57\u6bb5\u5b57\u7b26\u4e0d\u4f1a\u660e\u6587\u663e\u793a\uff0c\u800c\u662f\u4ee5\u661f\u53f7 * \u6216\u5706\u70b9 . \u66ff\u4ee3\u3002<\/p>\n

\u5355\u9009\u6309\u94ae\uff08Radio Buttons\uff09<\/strong><\/div>\n

<input type=\"radio\"> \u6807\u7b7e\u5b9a\u4e49\u4e86\u8868\u5355\u7684\u5355\u9009\u6846\u9009\u9879:<\/p>\n

\u5b9e\u4f8b<\/strong><\/p>\n

<form<\/span> action<\/span>=<\/span>\"\"<\/span>>\r\n<input<\/span> type<\/span>=<\/span>\"radio\"<\/span> name<\/span>=<\/span>\"sex\"<\/span> value<\/span>=<\/span>\"male\"<\/span>><\/span>\u7537<br<\/span>>\r\n<input<\/span> type<\/span>=<\/span>\"radio\"<\/span> name<\/span>=<\/span>\"sex\"<\/span> value<\/span>=<\/span>\"female\"<\/span>><\/span>\u5973\r\n<\/form><\/span><\/span><\/span><\/span><\/span><\/pre>\n

\u6d4f\u89c8\u5668\u663e\u793a\u6548\u679c\u5982\u4e0b:<\/p>\n\n\u7537
\n\u5973
\n<\/form>\n

\u590d\u9009\u6846\uff08Checkboxes\uff09<\/strong><\/div>\n

<input type=\"checkbox\"><\/span> \u5b9a\u4e49\u4e86\u590d\u9009\u6846\u3002<\/p>\n

\u590d\u9009\u6846\u53ef\u4ee5\u9009\u53d6\u4e00\u4e2a\u6216\u591a\u4e2a\u9009\u9879\uff1a<\/p>\n

\u5b9e\u4f8b<\/strong><\/p>\n

<form<\/span>>\r\n<input<\/span> type<\/span>=<\/span>\"checkbox\"<\/span> name<\/span>=<\/span>\"vehicle\"<\/span> value<\/span>=<\/span>\"Bike\"<\/span>><\/span>\u6211\u559c\u6b22\u81ea\u884c\u8f66<br<\/span>>\r\n<input<\/span> type<\/span>=<\/span>\"checkbox\"<\/span> name<\/span>=<\/span>\"vehicle\"<\/span> value<\/span>=<\/span>\"Car\"<\/span>><\/span>\u6211\u559c\u6b22\u5c0f\u6c7d\u8f66\r\n<\/<\/span>form<\/span>><\/span><\/span><\/span><\/pre>\n

\u6d4f\u89c8\u5668\u663e\u793a\u6548\u679c\u5982\u4e0b:<\/p>\n\n\u6211\u559c\u6b22\u81ea\u884c\u8f66
\n\u6211\u559c\u6b22\u5c0f\u6c7d\u8f66
\n<\/form>\n

\u63d0\u4ea4\u6309\u94ae(Submit)<\/strong><\/div>\n

<input type=\"submit\"><\/span> \u5b9a\u4e49\u4e86\u63d0\u4ea4\u6309\u94ae\u3002<\/p>\n

\u5f53\u7528\u6237\u5355\u51fb\u786e\u8ba4\u6309\u94ae\u65f6\uff0c\u8868\u5355\u7684\u5185\u5bb9\u4f1a\u88ab\u4f20\u9001\u5230\u670d\u52a1\u5668\u3002\u8868\u5355\u7684\u52a8\u4f5c\u5c5e\u6027 action \u5b9a\u4e49\u4e86\u670d\u52a1\u7aef\u7684\u6587\u4ef6\u540d\u3002<\/p>\n

action \u5c5e\u6027\u4f1a\u5bf9\u63a5\u6536\u5230\u7684\u7528\u6237\u8f93\u5165\u6570\u636e\u8fdb\u884c\u76f8\u5173\u7684\u5904\u7406:<\/p>\n

\u5b9e\u4f8b<\/strong><\/p>\n

<form<\/span> name<\/span>=<\/span>\"input\"<\/span> action<\/span>=<\/span>\"html_form_action.php\"<\/span> method<\/span>=<\/span>\"get\"<\/span>>\r\nUsername: <input<\/span> type<\/span>=<\/span>\"text\"<\/span> name<\/span>=<\/span>\"user\"<\/span>>\r\n<input<\/span> type<\/span>=<\/span>\"submit\"<\/span> value<\/span>=<\/span>\"Submit\"<\/span>>\r\n<\/<\/span>form<\/span>><\/span><\/span><\/span><\/span><\/pre>\n

\u6d4f\u89c8\u5668\u663e\u793a\u6548\u679c\u5982\u4e0b:<\/p>\n\nUsername:
\n<\/form>\n

\u5047\u5982\u60a8\u5728\u4e0a\u9762\u7684\u6587\u672c\u6846\u5185\u952e\u5165\u51e0\u4e2a\u5b57\u6bcd\uff0c\u7136\u540e\u70b9\u51fb\u786e\u8ba4\u6309\u94ae\uff0c\u90a3\u4e48\u8f93\u5165\u6570\u636e\u4f1a\u4f20\u9001\u5230 html_form_action.php \u6587\u4ef6\uff0c\u8be5\u9875\u9762\u5c06\u663e\u793a\u51fa\u8f93\u5165\u7684\u7ed3\u679c\u3002<\/p>\n

\u4ee5\u4e0a\u5b9e\u4f8b\u4e2d\u6709\u4e00\u4e2a method \u5c5e\u6027\uff0c\u5b83\u7528\u4e8e\u5b9a\u4e49\u8868\u5355\u6570\u636e\u7684\u63d0\u4ea4\u65b9\u5f0f\uff0c\u53ef\u4ee5\u662f\u4ee5\u4e0b\u503c\uff1a<\/p>\n

    \n
  1. post\uff1a\u6307\u7684\u662f HTTP POST \u65b9\u6cd5\uff0c\u8868\u5355\u6570\u636e\u4f1a\u5305\u542b\u5728\u8868\u5355\u4f53\u5185\u7136\u540e\u53d1\u9001\u7ed9\u670d\u52a1\u5668\uff0c\u7528\u4e8e\u63d0\u4ea4\u654f\u611f\u6570\u636e\uff0c\u5982\u7528\u6237\u540d\u4e0e\u5bc6\u7801\u7b49\u3002<\/li>\n
  2. get\uff1a\u9ed8\u8ba4\u503c\uff0c\u6307\u7684\u662f HTTP GET \u65b9\u6cd5\uff0c\u8868\u5355\u6570\u636e\u4f1a\u9644\u52a0\u5728 action \u5c5e\u6027\u7684 URL \u4e2d\uff0c\u5e76\u4ee5 ?\u4f5c\u4e3a\u5206\u9694\u7b26\uff0c\u4e00\u822c\u7528\u4e8e\u4e0d\u654f\u611f\u4fe1\u606f\uff0c\u5982\u5206\u9875\u7b49\u3002\u4f8b\u5982\uff1ahttps:\/\/www.runoob.com\/?page=1\uff0c\u8fd9\u91cc\u7684 page=1 \u5c31\u662f get \u65b9\u6cd5\u63d0\u4ea4\u7684\u6570\u636e\u3002<\/li>\n<\/ol>\n

    \u5b9e\u4f8b<\/strong><\/p>\n

    <!-- \u4ee5\u4e0b\u8868\u5355\u4f7f\u7528 GET \u8bf7\u6c42\u53d1\u9001\u6570\u636e\u5230\u5f53\u524d\u7684 URL\uff0cmethod \u9ed8\u8ba4\u4f4d GET\u3002 -->\r\n<form<\/span>>\r\n  <label<\/span>><\/span>Name:\r\n    <input<\/span> name<\/span>=<\/span>\"submitted-name\"<\/span> autocomplete<\/span>=<\/span>\"name\"<\/span>><\/span>
    \r\n  <\/<\/span>label<\/span>>\r\n  <button<\/span>><\/span>Save<\/<\/span>button<\/span>>\r\n<\/<\/span>form<\/span>>\r\n<!-- \u4ee5\u4e0b\u8868\u5355\u4f7f\u7528 POST \u8bf7\u6c42\u53d1\u9001\u6570\u636e\u5230\u5f53\u524d\u7684 URL\u3002 -->\r\n<form<\/span> method<\/span>=<\/span>\"post\"<\/span>>\r\n  <label<\/span>><\/span>Name:\r\n    <input<\/span> name<\/span>=<\/span>\"submitted-name\"<\/span> autocomplete<\/span>=<\/span>\"name\"<\/span>><\/span>
    \r\n  <\/<\/span>label<\/span>>\r\n  <button<\/span>><\/span>Save<\/<\/span>button<\/span>>\r\n<\/<\/span>form<\/span>>\r\n<!-- \u8868\u5355\u4f7f\u7528 fieldset, legend, \u548c label \u6807\u7b7e -->\r\n<form<\/span> method<\/span>=<\/span>\"post\"<\/span>>\r\n  <fieldset<\/span>>\r\n    <legend<\/span>><\/span>Title<\/<\/span>legend<\/span>>\r\n    <label<\/span>><input<\/span> type<\/span>=<\/span>\"radio\"<\/span> name<\/span>=<\/span>\"radio\"<\/span>><\/span> Select me<\/<\/span>label<\/span>>\r\n  <\/<\/span>fieldset<\/span>>\r\n<\/<\/span>form<\/span>><\/span><\/span><\/span><\/span><\/span><\/span><\/span><\/span><\/span><\/span><\/span><\/span><\/span><\/span><\/span><\/span><\/span><\/pre>\n
    HTML \u8868\u5355\u6807\u7b7e<\/strong><\/div>\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
    \u6807\u7b7e<\/th>\n\u63cf\u8ff0<\/th>\n<\/tr>\n
    <form><\/a><\/td>\n \u5b9a\u4e49\u4f9b\u7528\u6237\u8f93\u5165\u7684\u8868\u5355<\/td>\n<\/tr>\n
    <input><\/a><\/td>\n\u5b9a\u4e49\u8f93\u5165\u57df<\/td>\n<\/tr>\n
    <textarea><\/a><\/td>\n\u5b9a\u4e49\u6587\u672c\u57df (\u4e00\u4e2a\u591a\u884c\u7684\u8f93\u5165\u63a7\u4ef6)<\/td>\n<\/tr>\n
    <label><\/a><\/td>\n\u5b9a\u4e49\u4e86 <input> \u5143\u7d20\u7684\u6807\u7b7e\uff0c\u4e00\u822c\u4e3a\u8f93\u5165\u6807\u9898<\/td>\n<\/tr>\n
    <fieldset><\/a><\/td>\n\u5b9a\u4e49\u4e86\u4e00\u7ec4\u76f8\u5173\u7684\u8868\u5355\u5143\u7d20\uff0c\u5e76\u4f7f\u7528\u5916\u6846\u5305\u542b\u8d77\u6765<\/td>\n<\/tr>\n
    <legend><\/a><\/td>\n\u5b9a\u4e49\u4e86 <fieldset> \u5143\u7d20\u7684\u6807\u9898<\/td>\n<\/tr>\n
    <select><\/a><\/td>\n\u5b9a\u4e49\u4e86\u4e0b\u62c9\u9009\u9879\u5217\u8868<\/td>\n<\/tr>\n
    <optgroup><\/a><\/td>\n\u5b9a\u4e49\u9009\u9879\u7ec4<\/td>\n<\/tr>\n
    <option><\/a><\/td>\n\u5b9a\u4e49\u4e0b\u62c9\u5217\u8868\u4e2d\u7684\u9009\u9879<\/td>\n<\/tr>\n
    <button><\/a><\/td>\n\u5b9a\u4e49\u4e00\u4e2a\u70b9\u51fb\u6309\u94ae<\/td>\n<\/tr>\n
    <datalist><\/a>New<\/span><\/td>\n\u6307\u5b9a\u4e00\u4e2a\u9884\u5148\u5b9a\u4e49\u7684\u8f93\u5165\u63a7\u4ef6\u9009\u9879\u5217\u8868<\/td>\n<\/tr>\n
    <keygen><\/a>New<\/span><\/td>\n\u5b9a\u4e49\u4e86\u8868\u5355\u7684\u5bc6\u94a5\u5bf9\u751f\u6210\u5668\u5b57\u6bb5<\/td>\n<\/tr>\n
    <output><\/a>New<\/span><\/td>\n\u5b9a\u4e49\u4e00\u4e2a\u8ba1\u7b97\u7ed3\u679c<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n","protected":false},"excerpt":{"rendered":"

    \u5b9e\u4f8b \u4ee5\u4e0b\u5b9e\u4f8b\u521b\u5efa\u4e86\u4e00\u4e2a\u8868\u5355\uff0c\u5305\u542b\u4e24\u4e2a\u8f93\u5165\u6846\uff1a <form action=””> First na […]<\/p>\n","protected":false},"author":1470,"featured_media":250340,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-250330","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/250330","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/1470"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=250330"}],"version-history":[{"count":12,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/250330\/revisions"}],"predecessor-version":[{"id":250343,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/250330\/revisions\/250343"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/250340"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=250330"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=250330"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=250330"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}