首页 > 解决方案 > 如何在没有提交按钮的情况下将页面值传递给其他页面

问题描述

该页面在 POST 的 infoCheck.php 上传递。

首先,我将继续如下。

<form id="theForm" method = "POST" action = "infoCheck.php"
   <input type = "hidden" name = "name" value = "100">
   <input type = "submit" value = "Input">
</form>

但是,在提交之前,只有与名称对应的值必须在页面打开时立即发送。一定有距离。即使我搜索了,我也只能看到如何使用提交......我该怎么办?

标签: javascriptphpjsp

解决方案


如果你使用 jQuery,试试这个:

HTML

<form id="theForm" method="POST" action="infoCheck.php">
  <input type="hidden" name="name" value="100">
  <input type="submit" value="Input">
</form>

jQuery:

<script type="text/javascript">
    $(function() {
        $("#theForm").submit();
    });
</script>

推荐阅读