ข้อมูลอ้างอิงHTML

HTML โดยตัวอักษร HTML ตามหมวดหมู่ รองรับ HTML Browser แอตทริบิวต์ HTML HTML Global Attributes เหตุการณ์ HTML HTML สี HTML Canvas HTML เสียง/วิดีโอ ชุดอักขระ HTML HTML Doctypes การเข้ารหัส URL HTML รหัสภาษา HTML รหัสประเทศ HTML ข้อความ HTTP วิธี HTTP ตัวแปลง PX เป็น EM แป้นพิมพ์ลัด


HTML <button> รูปแบบแอตทริบิวต์

❮ แท็ก 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:

  • An absolute URL - the full address of a page (like href="http://www.example.com/formresult.asp")
  • A relative URL - points to a file within the current site (like href="formresult.asp")

❮ แท็ก HTML <button>