【问题标题】:onclick input type submitonclick 输入类型提交
【发布时间】:2013-06-04 18:15:27
【问题描述】:

在一个表单中,我有一个包含 PHP 文件 (editor.php) 的 <iframe>。这个 PHP 文件包含一个 HTML 表单。

好吧,当我执行“提交表单”时,我调用了同一个 PHP 文件,例如 main.php。 当我按下提交按钮时,我有“onclick 方法”,它在 editor.php 中调用 Javascript 函数。该函数执行表单。

我的问题是主窗体执行正确,但第二个窗体没有。

在editor.php形式的第二个循环中什么也没收到。

【问题讨论】:

  • 添加参考来源
  • 您能发布代码的相关部分吗?这将有助于发现问题。

标签: php javascript html iframe


【解决方案1】:
**Check this way it will work as you expected**
//main.php
<html>
<head>
<script type="text/javascript">
    function validateMain()
    {
       alert('main'); 
    }
    function validateSub()
    {
        alert('sub'); 
    }
</script>
</head>
<body>  
<form id="main"  onsubmit="return validateMain();">
        <input type="text" name="first" id="first"/>
        <input type="submit" value="Submit Main"/> 
 </form>
 <iframe name="ifr-form" id="ifr-form" src="test.html"></iframe> 
</body>
</html>

//test.html the second form included through iframe

    <!DOCTYPE html>
<html>
    <head>
        <title></title>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    </head>
    <body>
        <div>


 <form id="sub" onclick="return window.top.validateSub();">
        <input type="text" name="first" id="second"/>
        <input type="button" value="Submit Sub" /> 
      </form>

        </div>
    </body>
</html>

【讨论】:

  • 谢谢Sam,但是第二种形式要抢救形式的变量并写入html文件。
  • @jordi ,, 查看代码 jordi........你可以吗?或者你期待更多……如果你想要的话,请尽快告诉我
  • @jordi 给我这个内容投赞成票,,,并清楚地告诉我询问的确切方式,,,,,,,把你身边的代码的相关部分给我跨度>
【解决方案2】:

您必须检查 php 和 iframe 是否兼容,据我所知,我认为框架和 php 不会提供任何输出,希望对您有所帮助。

【讨论】:

  • 由于 iframe 只是显示 .php 文件的地方,因此无需担心“兼容性”问题。
  • 调用 iframe...
猜你喜欢
  • 2017-01-19
  • 1970-01-01
  • 1970-01-01
  • 2020-04-02
  • 1970-01-01
  • 2020-01-09
  • 1970-01-01
  • 1970-01-01
  • 2013-02-14
相关资源
最近更新 更多