我正在开发一个代码,它将值作为输入,并在提交时显示表单,显示结果,代码如下:
<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> </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> </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>
问题是,当页面完全加载时,应该提交表单,但不能提交表单。有什么问题,救救我!提前致谢
答案 0 :(得分: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> </TD></TR>
<TR>
<TD align="right" width="40%">Regd. No:</TD>
<TD><INPUT type="text" name="stid" value=""></TD>
</TR>
<TR><TD> </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">
。请勿使用名称为submit
或id。
而且更好的是,
<script>
window.ready = function(){
document.getElementById('myform').submit();
};
</script>
答案 1 :(得分:1)
应该有所帮助:
$(document).ready(function () {
$('#myform').trigger('submit'); });
在页面加载后,我仍然没有得到提交表单的重点。
答案 2 :(得分:1)
试
<script>
function submitme()
{
document.forms["performance"].submit();
}
</script>
或
<script>
function submitme()
{
document.forms[0].submit();
}
</script>