22
表表 (Form) http://www.w3schools.com/html/html_ forms.asp

表單 (Form)

Embed Size (px)

DESCRIPTION

表單 (Form). . … Ex. … . method. method="get" URL: http://www.abc.com/join.php?uid=ycc&pwd=mypwd HTTP message entity: none 不可超過 256 個字元 method="post" - PowerPoint PPT Presentation

Citation preview

Page 1: 表單  (Form)

表單 (Form)

http://www.w3schools.com/html/html_forms.asp

Page 2: 表單  (Form)

<form>

<form id="…" action="…" method="…" enctype="…">…</form>

Ex. <form id="joinForm" action="join.php" method="post">…</form>

Page 3: 表單  (Form)

method

method="get" URL: http://www.abc.com/join.php?

uid=ycc&pwd=mypwd HTTP message entity: none 不可超過 256 個字元

method="post" URL: http://www.abc.com/join.php HTTP message entity: uid=ycc&pwd=mypwd

Page 4: 表單  (Form)

Form Exampletext

password

textarea

checkbox

radio

select

file

submit, reset, button

Page 5: 表單  (Form)

<input type="text" … />

<input type="text" id="…" name="…" size="…" maxlength="…" value="…" />

Ex.User Name:<input type="text" id="uid" name="uid" size="8" maxlength="20" placeholder="Your id" /><br />

Page 6: 表單  (Form)

<input type="password" … />

<input type="password" id="…" name="…" size="…" maxlength="…" value="…" />

Ex.Password:<input type="password" id="pwd" name="pwd" size="10" maxlength="20" /><br />

Page 7: 表單  (Form)

<textarea …>…</textarea>

<textarea id="…" name="…" cols="…" rows="…">…</textarea>ex. Comments: <br /><textarea id="cmts" name="cmts" cols="40" rows="5"> </textarea><br />

Page 8: 表單  (Form)

<input type="checkbox" … />

<input type="checkbox" id="…" name="…" value="…" checked />ex.Members:<input type="checkbox" id="yahoo" name="yahoo" value="yahoo" /> Yahoo!<input type="checkbox" id="google" name="google" value="google" checked /> Google<input type="checkbox" id="youtube" name="youtube" value="youtube" /> Youtube<br/>

Page 9: 表單  (Form)

<input type="radio" … />

<input type="radio" id="…" name="…" value="…" checked />ex.Payment:<input type="radio" id="pay" name="pay" value="Visa" checked />Visa<input type="radio" id="pay" name="pay" value="Master" />Master<input type="radio" id="pay" name="pay" value="JCB" />JCB

Page 10: 表單  (Form)

<select …><option …>…</option></select>

<select id="…" name="…"><option value="…" selected >…</option>…</select>Ex.Year: <select id="year" name="year"><option>2009</option><option value="2010">2010</option><option>2011</option><option selected>2012</option></select>

Page 11: 表單  (Form)

<select …><option …>…</option></select>

<select id="…" name="…" size="…" multiple="multiple">

<option value="…" selected >…</option></select>Ex.Web Technologies:<br /> <select id="wts" name="wts" size="5" multiple="multiple"><option selected >HTML</option><option>XHTML</option><option>CSS</option><option selected >JavaScript</option><option>ASP</option><option selected >PHP</option></select>

Page 12: 表單  (Form)

<optgroup label="…">…</optgroup>

<select name=" 個人資料 " size="6" multiple="multiple"> <optgroup label=" 血型 "> <option>A</option> <option>B</option> <option>AB</option> <option>O</option> </optgroup> <optgroup label=" 會的網頁技術 "> <option>JavaScript</option> <option>VBScript</option> <option>PHP</option> <option>ASP.NET</option> </optgroup></select>

Page 13: 表單  (Form)

<input type="file" … /><form id="…" action="…" method="post" enctype="multipart/form-data"><input type="file" id="…" name="…" /></form>ex.<form id="join" action="join.php" method="post" enctype="multipart/form-data">Upload pdf file: <input type="file" id="pdf" name="pdf" /></form>

size="…" maxlength="…"

Page 14: 表單  (Form)

POST /ycchen/www2011/ex/join.php HTTP/1.1Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*Referer: http://www.im.ncnu.edu.tw/~ycchen/www2009/ex/form.htmlAccept-Language: zh-tw,zh-cn;q=0.5Content-Type: multipart/form-data; boundary=---------------------------7d934db290122UA-CPU: x86Accept-Encoding: gzip, deflateUser-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; GTB5; .NET CLR 1.1.4322; .NET CLR 2.0.50727; InfoPath.1)Host: www.im.ncnu.edu.twContent-Length: 1720496Connection: Keep-AliveCache-Control: no-cache

-----------------------------7d934db290122Content-Disposition: form-data; name="uid"

Your id-----------------------------7d934db290122Content-Disposition: form-data; name="pwd"

mypwd-----------------------------7d934db290122Content-Disposition: form-data; name="google"

google

Page 15: 表單  (Form)

-----------------------------7d934db290122Content-Disposition: form-data; name="wts"

HTML-----------------------------7d934db290122Content-Disposition: form-data; name="wts"

XHTML-----------------------------7d934db290122Content-Disposition: form-data; name="pdf"; filename="C:\paper\IEEEMembershipApp.pdf"Content-Type: application/pdf

%PDF-1.3%....35 0 obj<< /Linearized 1 /O 37 /H [ 1122 330 ] /L 1719209 /E 701707 /N 3 /T 1718391

Page 16: 表單  (Form)

<input type="hidden" … />

<input type="hidden" id="…" name="…" value="…" />

ex. <input type="hidden" id="isM" name="isM"

value="true" /><input type="hidden" id="page" name="page"

value="17" />

Page 17: 表單  (Form)

1. <input type="submit" />2. <input type="submit" value="OK" />3. <input type="reset" />4. <input type="reset" value="Clear" />5. <input type="button" value="Press this

button" />1 2 3 4 5

Page 18: 表單  (Form)

<input type="image" … />

<input type="image" src="…" alt="…" />

ex.<input type="image" src="ok.jpg"

alt="OK" />

Page 19: 表單  (Form)

<button><img …>…</button>

<button type="…" ><img …>…</button>

ex.<button type="reset"><img src="r1.gif" alt="reset" width="34"

/><br />Reset</button>

Page 20: 表單  (Form)

<fieldset><legend>…</legend></fieldset>

<fieldset> <legend> 填入個人資料 </legend> <ol> <li> 姓名 : <input type="text" id="name" name="name"

/></li> <li> 電子信箱 : <input type="text" id="email"

name="email" /></li> <li> 電話 : <input type="text" id="state" name="state"

/></li> </ol></fieldset>ex7-4.html

Page 21: 表單  (Form)

<label><label for="male">Male</label><input type="radio" name="sex" id="male"

/><br /><label for="female">Female</label><input type="radio" name="sex" id="female" />

<label>Male<input type="radio" name="sex" /></label><br />

<label>Female<input type="radio" name="sex" /></label>

Page 22: 表單  (Form)

What's New in HTML5 Forms Elements

<datalist>, <keygen>, <output> http://www.w3schools.com/html/html_form_elements.asp

Input Types color, date, datetime, datetime-local, email, month,

number, range, search, tel, time, url, week http://www.w3schools.com/html/html_form_input_types.asp

Input Attributes autocomplete, autofocus, form, formaction, formenctype,

formmethod, formnovalidate, formtarget, height, width, list, min, max, multiple, pattern(regexp), placeholder, required, step

http://www.w3schools.com/html/html_form_attributes.asp