「JavaScript」HTMLFormElement.submitでフォームを送信する

構文
HTMLFormElement.submit();

このメソッドはフォームの送信ボタンをクリックするのと同じ動作をします。
使用例
JSコード

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function testFunc(actionname,id){
document.forms["userForm"].action.value = actionname;
document.forms["userForm"].uid.value = id;
document.forms["userForm"].submit();
}
function testFunc(actionname,id){ document.forms["userForm"].action.value = actionname; document.forms["userForm"].uid.value = id; document.forms["userForm"].submit(); }
function testFunc(actionname,id){
   document.forms["userForm"].action.value = actionname;
   document.forms["userForm"].uid.value = id;
   document.forms["userForm"].submit();
 
}

htmlコード

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<input type="button" name="create" value="作成" onclick="testFunc('create','345')"
<input type="button" name="create" value="作成" onclick="testFunc('create','345')"
<input type="button" name="create" value="作成" onclick="testFunc('create','345')"

 

JavaScript

Posted by arkgame