[英]how to pass parameter in action tag?
我想將res
變量作為表單操作傳遞。 HTML可以做到嗎?
<script>
var name =$("#name").val();
var file =$("#file").val();
var res= localhost:8080 + "/test/reg?&name="+name+"&file=" +file ;
</script>
<form action="res" id ="form" method="post" enctype="multipart/form-data">
Name:<input type="text" name="name" id="name"/>
Upload:<input type="file" name="file" id="file"/>
</form>
document.forms["form"].submit();
提交前設置動作屬性:
var form = document.forms["form"];
form.action = res;
form.submit();
如果用戶可以手動提交此表單,則可以使用onsubmit
事件:
form.onsubmit = function(){
this.action = res;
};
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.