HTML <button> รูปแบบแอตทริบิวต์
ตัวอย่าง
แบบฟอร์มที่มีปุ่มส่งสองปุ่ม ปุ่มส่งปุ่มแรกส่งข้อมูลแบบฟอร์มไปที่ "action_page.php" และปุ่มที่สองส่งไปที่ "action_page2.php":
<form action="/action_page.php" method="get">
<label for="fname">First name:</label>
<input type="text" id="fname"
name="fname"><br><br>
<label for="lname">Last name:</label>
<input type="text" id="lname" name="lname"><br><br>
<button
type="submit">Submit</button>
<button type="submit" formaction="/action_page2.php">Submit to another page</button>
</form>
ความหมายและการใช้งาน
แอตทริบิวต์formaction
ระบุตำแหน่งที่จะส่งข้อมูลแบบฟอร์มเมื่อส่งแบบฟอร์ม แอตทริบิวต์นี้จะแทนที่แอตทริบิวต์ของแบบaction
ฟอร์ม
คุณลักษณะformaction
นี้ใช้สำหรับปุ่มที่มี
type="submit"
.
รองรับเบราว์เซอร์
ตัวเลขในตารางระบุเบราว์เซอร์รุ่นแรกที่สนับสนุนแอตทริบิวต์อย่างเต็มที่
Attribute | |||||
---|---|---|---|---|---|
formaction | 9.0 | 10.0 | 4.0 | 5.1 | 15.0 |
ไวยากรณ์
<button type="submit" formaction="URL">
ค่าแอตทริบิวต์
Value | Description |
---|---|
URL | Specifies where to send the form data. Possible values:
|
❮ แท็ก HTML <button>