i’m trying to submit a form using variants of onload=‘formname.submit();’ and am getting errors… can someone help me with getting a form submitted automatically when a page loads…?
thanks much,
glenn
i’m trying to submit a form using variants of onload=‘formname.submit();’ and am getting errors… can someone help me with getting a form submitted automatically when a page loads…?
thanks much,
glenn
<form id=“myForm”>
…
</form>
document.getElementById(‘myForm’).submit();
also you can use
<form name=“myForm”>
…
</form>
<script>
document.myForm.submit();
</script>
I need this same functionality.
Here is my code. As you can see, I have TWO places where the script is supposed to automatically submit itself. But neither of them work. What am I doing wrong?
<?php
require_once("ShoppingCart.class");
session_start();
$cart=$_SESSION['cart'];
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Checkout </title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script type="text/javascript" language="javascript">
function submitform(){
document.getElementById('myForm').submit();
}
</script>
</head>
<body onload="submitform()">
<form name="myForm" action="https://www.linkpointcentral.com/lpc/servlet/lppay" method="post" target="_blank">
<input type='hidden' name='storename' value='456'>
<input type='hidden' name='amount' value='5.00'>
</form>
<script type="text/javascript" language="javascript">
document.getElementById('myForm').submit();
</script>
</body>
</html>
btw, the above script worked in IE, (once I take the “target=_blank” attribute out)
but NOT in Mozilla Firefox, which is my browser of choice.
GOT IT WORKING IN FIREFOX…
I just changed the second one to document.myForm.submit(); and now it works in Mozilla Firefox.
Thanks