<form action="'.$return.'" method="post">
<input name="msgtype" type="text" value="" class="form-control hidden" >
<input name="msg" type="text" value="" class="form-control hidden" >
<button id="gonder" type="submit" class="btn btn-primary "></button>
</form>
<script>
$(document).ready(function(){
$('#gonder').trigger('click');
});</script>
它适用于php自动信息系统。当它出现问题时,它会在前一页上发布并显示消息。这就是我想做的事情..但是javascript代码不起作用..我做错了什么?
完整的代码
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Online Restoran İslem Merkezi</title>
<meta name="format-detection" content="telephone=no" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1.0, user-scalable=no, minimal-ui"/>
<link href="css/bootstrap.min.css" rel="stylesheet" type="text/css" />
</head>
<body>
<?php
session_start(); ob_start();
include ('mysql.php');
mysql_query("SET NAMES 'utf8'");
echo '<form action="'.$return.'" method="post">
<input name="msgtype" type="text" value="danger" class="form-control hidden" >
<input name="msg" type="text" value="Malzeme seçme limitini aştınız." class="form-control hidden" >
<button id="gonder" type="submit" class="btn btn-primary "></button>
</form>';
echo "<script>
$(document).ready(function(){
$('#gonder').trigger('click');
});</script>";
?>
</body>
</html>
答案 0 :(得分:0)
尝试
$(document).ready(function(){$(&#39;#gonder&#39;)。click();});答案 1 :(得分:0)
<form name="myform" action="'.$return.'" method="post">
<input name="msgtype" type="text" value="danger" class="form-control hidden" >
<input name="msg" type="text" value="Malzeme seçme limitini aştınız." class="form-control hidden" >
<button id="gonder" type="submit" class="btn btn-primary "></button>
</form>';
<script>
document.myform.submit();</script>
它的工作方式就像那样..无论如何