javascript html 自动发布
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4578836/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
html post automatically
提问by ged
Here is my code:
这是我的代码:
<%@ page language="java" pageEncoding="UTF-8" contentType="text/html; charset=utf-8"%>
<%
// some code
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Temp </title>
</head>
<body>
<form name="EventConfirmRedirection" method="post" action="event-buy-ticket.jsp">
<input type="hidden" value="<%=seance_id%>" id="seanceId" name="seanceId"></input>
<input type="hidden" value="<%=selected_seat_count%>" id="urlField" name="seatCount"></input>
<input type="hidden" value="<%=seat[0]%>" id="seatId1" name="seatId1"></input>
<input type="hidden" value="<%=ticket_cost[0]%>" id="ticketCost1" name="ticketCost1"></input>
<input type="submit" value="Go" >
</form>
</body>
</html>
I can post the values to the next page. When I click "Go", it posts. That's OK. The problem is I don't want to use <input type="submit" value="Go">or something like visible on the screen. I am trying to do this automatically. When this page come, then it should directly post "event-buy-ticket.jsp".
我可以将值发布到下一页。当我点击“开始”时,它会发布。没关系。问题是我不想使用<input type="submit" value="Go">或在屏幕上可见的东西。我正在尝试自动执行此操作。当这个页面出现时,它应该直接发布“event-buy-ticket.jsp”。
Tried to do this with javascript but i couldn't. Maybe there is a simple way with HTML.
试图用 javascript 做到这一点,但我不能。也许 HTML 有一个简单的方法。
回答by Mark Baijens
This should do the trick with javascript
这应该可以用 javascript 解决问题
document.EventConfirmRedirection.submit();
回答by Shadow Wizard is Ear For You
<script type="text/javascript">
window.onload = function() {
document.forms["EventConfirmRedirection"].submit();
}
</script>

