How to autosubmit data html form?

2019-08-07 07:18发布

I have this simple form:

<form ENCTYPE="multipart/form-data" action="story.php" method="POST">
<input type="submit" value="Show files">
<input type="hidden" name="emailp" id="emailp" value="">
</form>

I fill the "value" with a querystring parameter by external iframe and javascript. Ok. Now I need to send this data to a php file. My idea was go for autosubmit. Now I can do that with a button like "show files", but I dont need a button but something that send the value automatically. Is it possible do that?

2条回答
该账号已被封号
2楼-- · 2019-08-07 07:32

If you add an ID to that form you could do it like this .

$('#FORM_ID').submit(); with jQuery

form = document.getElementById('FORM_ID');
   form.submit();

or with JavaScript

查看更多
相关推荐>>
3楼-- · 2019-08-07 07:50

Call a this JS code that submits the form after you set the value of the input.

document.getElementById("storyForm").submit();

HTML:

<form ENCTYPE="multipart/form-data" action="story.php" method="POST" id="storyForm">
<input type="submit" value="Show files">
<input type="hidden" name="emailp" id="emailp" value="">
</form>
查看更多
登录 后发表回答