คุณสมบัติ value ของ HTML DOM Input submit เกี่ยวข้องกับองค์ประกอบ input ที่มี type=”submit” และแอตทริบิวต์ value ใช้สำหรับส่งคืนค่าของแอตทริบิวต์ value ของปุ่ม submit หรือตั้งค่ามัน คุณสมบัติ value สำหรับปุ่ม submit เปลี่ยนข้อความที่แสดงบนปุ่ม เนื่องจากค่าเริ่มต้นคือ “Submit”
ไวยากรณ์
ไวยากรณ์สำหรับการตั้งค่าคุณสมบัติ value:
submitObject.value = text;
ที่นี่ text ใช้ระบุข้อความที่แสดงบนปุ่ม submit
ตัวอย่าง
มาดูตัวอย่างสำหรับคุณสมบัติ value ของ input submit:
<!DOCTYPE html> <html> <body> <h1>Input submit Value property</h1> <form style="border:solid 2px green;padding:2px"> UserName: <input type="text" id="USR"> <br> Location: <input type="text" id="Loc"> <br><br> <input type="submit" id="SUBMIT1"> </form> <p>เปลี่ยนค่าขององค์ประกอบด้านบนโดยคลิกปุ่มด้านล่าง</p> <button onclick="changeValue()">CHANGE</button> <p id="Sample"></p> <script> function changeValue() { document.getElementById("SUBMIT1").value="Form_Submit"; document.getElementById("Sample").innerHTML="The submit button value is changed and the value can be seen on the button itself"; } </script> </body> </html>
ผลลัพธ์
จะได้ผลลัพธ์ดังนี้:

เมื่อคลิกปุ่ม CHANGE:
