Reputation: 967
I want to pass the res
variable as a form action. Is this possible with 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();
Upvotes: 1
Views: 234
Reputation: 64526
Set the action property before submitting it:
var form = document.forms["form"];
form.action = res;
form.submit();
If the user can submit this form manually then you can use the onsubmit
event:
form.onsubmit = function(){
this.action = res;
};
Upvotes: 1