HTML DOM 輸入提交表單屬性
HTML DOM 輸入提交表單屬性用於返回包含指定的提交按鈕的表單引用。如果提交按鈕在表單外部,它將僅返回 NULL。此屬性是隻讀屬性。
語法
下面是輸入提交表單屬性的語法 -
submitObject.form
示例
讓我們看一個輸入提交表單屬性的示例 -
<!DOCTYPE html> <html> <body> <h1>Input submit form Property</h1> <form action="Sample_page.php" id="FORM_1" 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>Get the form id by clicking on the below button</p> <button type="button" onclick="formId()">GET FORM</button> <p id="Sample"></p> <script> function formId() { var P=document.getElementById("SUBMIT1").form.id; document.getElementById("Sample").innerHTML = "The id of the form containing the submit button is: "+P ; } </script> </body> </html>
輸出
這將產生以下輸出 -
單擊 GET FORM -
廣告