javascript表单提交修改动作
我正在尝试根据要发布的文件的名称修改表单的发布网址。非常感谢任何建议。这是代码(不起作用):
<script type="text/javascript">
function submit_form()
{
document.uploadform.action = "upload?name=" + document.uploadform.codejar.value;
return 1;
}
</script>
<form name="uploadform" method="post" onsubmit="return submit_form();">
<table>
<tr><td>Select your jar to upload</td></tr>
<tr><td> <input type="file" name="codejar" style="width: 400"></td></tr>
<tr><td><input type="submit" name="send" value="Upload jar"></td></tr>
</table>
</form>
I'm trying to modify the post url of a form depending on the name of the file being posted. Any suggestions very much appreciated. Here is the code (which doesn't work):
<script type="text/javascript">
function submit_form()
{
document.uploadform.action = "upload?name=" + document.uploadform.codejar.value;
return 1;
}
</script>
<form name="uploadform" method="post" onsubmit="return submit_form();">
<table>
<tr><td>Select your jar to upload</td></tr>
<tr><td> <input type="file" name="codejar" style="width: 400"></td></tr>
<tr><td><input type="submit" name="send" value="Upload jar"></td></tr>
</table>
</form>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
“我正在尝试让它对文件进行简单的 http post,以文件名作为参数的 url”
然后执行此操作:
...并考虑将“发送”按钮更改为
"I'm trying to get it to do a plain http post of the file, to a url with the filename as a parameter"
Just do this then:
...and think about changing your "send" button to
为什么你需要这样做?
表单发布后,您应该能够访问该信息。
此外,浏览器在从文件输入获取值时可以发送不同的内容。
Why would you need to do that?
You should be able to access that once the form is POSTed.
Also, browsers can send different things when getting the value from file inputs.