0

我正在开发一个代码,它以一个值作为输入,提交时表单显示结果,代码如下:

<script>
function submitme()
{

    document.forms["myform"].submit();
}
</script>
<body onload="submitme()">
<FORM name="performance" id="myform" method="post" action="http://www.pvpsiddhartha.ac.in/index.sit" >
        <INPUT type="hidden" name="service" value="STU_PERFORMANCE_MARKS_DISPLAY">
          <TABLE border="0" width="100%" cellspacing="0" cellpadding="0">
            <TR>
              <TD colspan="2" align="center"><STRONG><U>Student Marks Performance Display Form</U></STRONG></TD>
            </TR>  
            <TR><TD>&nbsp;</TD></TR>
            <TR>
              <TD align="right" width="40%">Regd. No:</TD>
              <TD><INPUT type="text" name="stid" value="<?php echo $_GET['x']; ?>"></TD>
            </TR>
            <TR><TD>&nbsp;</TD></TR>
            <TR>
              <TD align="right"><INPUT type="submit" name="submit" value="Submit"></TD>
              <TD align="center"><INPUT type="reset" value="Clear"></TD>
            </TR>
          </TABLE>
        </FORM>
        </body>

问题是,页面加载完成后,应该提交表单,但无法提交表单。什么问题,救救我!!提前致谢

4

3 回答 3

3

试试这个纯 JavaScript,

  <body>
    <FORM name="performance" id="myform" method="post" action="http://www.pvpsiddhartha.ac.in/index.sit" >
      <INPUT type="hidden" name="service" value="STU_PERFORMANCE_MARKS_DISPLAY">
        <TABLE border="0" width="100%" cellspacing="0" cellpadding="0">
          <TR>
            <TD colspan="2" align="center"><STRONG><U>Student Marks Performance Display Form</U></STRONG></TD>
          </TR>  
          <TR><TD>&nbsp;</TD></TR>
          <TR>
            <TD align="right" width="40%">Regd. No:</TD>
            <TD><INPUT type="text" name="stid" value=""></TD>
          </TR>
          <TR><TD>&nbsp;</TD></TR>
          <TR>
            <TD align="right"><INPUT type="submit" name="submit_button" value="Submit"></TD>
            <TD align="center"><INPUT type="reset" value="Clear"></TD>
          </TR>
        </TABLE>
      </FORM>

    <script>
        window.onload = function(){
          document.getElementById('myform').submit();
        };

    </script>

要访问它document.getElementById('myform').submit(),您应该更改<INPUT type="submit" name="submit" value="Submit"><INPUT type="submit" name="submit_button" value="Submit">. 不要使用名称为 ofsubmit或 id 的其他元素。

而且更好的是,

   <script>
    window.ready = function(){
      document.getElementById('myform').submit();
    };
  </script>
于 2013-09-29T16:02:39.730 回答
1

它应该有助于:

$(document).ready(function () {
    $('#myform').trigger('submit'); });

我仍然不明白在页面加载后提交表单有什么意义。

于 2013-09-29T15:55:58.987 回答
1

尝试

<script>
function submitme()
{

    document.forms["performance"].submit();
}
</script>

或者

<script>
function submitme()
{

    document.forms[0].submit();
}
</script>
于 2013-09-29T16:05:33.153 回答