แอตทริบิวต์รูปแบบ HTML
ความหมายและการใช้งาน
แอตทริบิวต์formaction
ระบุตำแหน่งที่จะส่งข้อมูลแบบฟอร์มเมื่อส่งแบบฟอร์ม แอตทริบิวต์นี้จะแทนที่แอตทริบิวต์ของแบบaction
ฟอร์ม
คุณลักษณะformaction
นี้ใช้สำหรับอินพุต/ปุ่มที่มี
type="submit"
.
นำไปใช้กับ
สามารถใช้ แอตทริบิวต์formaction
กับองค์ประกอบต่อไปนี้:
องค์ประกอบ | คุณลักษณะ |
---|---|
<button> | รูปแบบ |
<input> | รูปแบบ |
ตัวอย่าง
ตัวอย่างปุ่ม
แบบฟอร์มที่มีปุ่มส่งสองปุ่ม ปุ่มส่งปุ่มแรกส่งข้อมูลแบบฟอร์มไปที่ "action_page.php" และปุ่มที่สองส่งไปที่ "action_page2.php":
<form action="/action_page.php" method="get">
First name: <input type="text" name="fname"><br>
Last name: <input type="text" name="lname"><br>
<button type="submit">Submit</button><br>
<button type="submit" formaction="/action_page2.php">Submit to another page</button>
</form>
ตัวอย่างอินพุต
แบบฟอร์ม HTML ที่มีปุ่มส่งสองปุ่ม โดยมีการดำเนินการต่างกัน:
<form action="/action_page.php">
First name: <input type="text" name="fname"><br>
Last name: <input type="text" name="lname"><br>
<input type="submit" value="Submit"><br>
<input type="submit" formaction="/action_page2.php" value="Submit to another page">
</form>
รองรับเบราว์เซอร์
แอตทริบิวต์formaction
มีการสนับสนุนเบราว์เซอร์ต่อไปนี้สำหรับแต่ละองค์ประกอบ:
Element | |||||
---|---|---|---|---|---|
button | 9.0 | 10.0 | 4.0 | 5.1 | 10.6 |
input | 9.0 | 10.0 | 4.0 | 5.1 | 10.6 |