Mozilla form submit problem

tonto

Perch
I have a problem,

I am trying to use the following vbscript to automatically submit a form. It works in IE but not in Mozilla. Does anyone have any suggestions on how to make this work?

<form name="frmUserCode" id="frmUserCode" method="POST" action="http://www.mysite.com/login.asp">
<input type="hidden" name="UCD" id="UCD" value="<% =str_UserCode % ">
</form>

<script type="text/vbscript" language="vbscript">
<!--
Document.GetElementByID("frmUserCode").Submit()
-->
</script>
 
tonto said:
I have a problem,

I am trying to use the following vbscript to automatically submit a form. It works in IE but not in Mozilla. Does anyone have any suggestions on how to make this work?

<form name="frmUserCode" id="frmUserCode" method="POST" action="http://www.mysite.com/login.asp">
<input type="hidden" name="UCD" id="UCD" value="<% =str_UserCode % ">
</form>

<script type="text/vbscript" language="vbscript">
<!--
Document.GetElementByID("frmUserCode").Submit()
-->
</script>

I don't think Mozilla supports vbscript and, therefore, I think you'll have to rewrite the script in javascript. Furthermore, only some versions of Netscape support the GetElementByID method, and some browsers support a document.all object.

This code might get you started, but I'm not sure it is complete enough to support ALL browsers (I doubt it). Also note that that this is untested and I can't remember with certainty how to use the document.all object (could be document.all.frmUserCode, could be document.all["frmUserCode"], or could be something else). Do some web searches on javascript and document.all and you can find out more.

Code:
<script language="javascript">
<!-- 
if(document.all){ 
    // ????? not sure here
    frm=document.all.frmUserCode
    // frm=document.all["frmUserCode"]
}
if(document.getElementById){ 
    frm=document.getElementById("frmUserCode")
}
if (frm) frm.submit();
-->
</script>

riley
 
Thanks for the fast reply riley. I just tried the javascript version and it works exactly the same as the vbscript version. Works great with IE but doesn't work with Mozilla firefox.

By the way, I tried .frmUserCode and ["frmUserCode"]. Neither one seemed to make a difference. Any other ideas?
 
tonto said:
Thanks for the fast reply riley. I just tried the javascript version and it works exactly the same as the vbscript version. Works great with IE but doesn't work with Mozilla firefox.

By the way, I tried .frmUserCode and ["frmUserCode"]. Neither one seemed to make a difference. Any other ideas?

Yes, I think we have made this overly complicated. Try this:
Code:
<script language="javascript">
<!-- 
document.frmUserCode.submit();
-->
</script>

riley
 
Tried it and now get the error in IE "object doesn't support this property or method."

Mozilla does nothing.

Any other suggestions?
 
Oh the joys of free enterprise with no standards...

I found the problem;

S vs. s in submit. Submit (bad). submit (good) in Mozilla firefox.

S vs. s in submit. Submit (good). submit (good) in IE.
 
tonto said:
Oh the joys of free enterprise with no standards...

I found the problem;

S vs. s in submit. Submit (bad). submit (good) in Mozilla firefox.

S vs. s in submit. Submit (good). submit (good) in IE.

Sorry tonto, I didn't even think of it.

Maybe this will help (note the different cases):
Code:
<script language="javascript">
<!--
if (document.frmUserCode.Submit) {
    document.frmUserCode.Submit();
}
else {
    document.frmUserCode.submit();
}
-->
</script>

riley
 
3 days of research - finally realized that my html page did not have <body></body> tags! This code should work for auto submit form in firefox / mozilla browser.


<head>
<title>Auto Submit</title>
</head>
<body>
<form method=post name=controlform id=controlform action="http://www.sliceofshit.com"><input type=submit name=button value="pushme"></form>
<script language=javascript>
document.controlform.submit();
</script>
</body>



Hope this post helps somebody! I created an account just so that I could post this ;)

Addendum! (6/24/05) - Internet Explorer for Mac version 5.0 (at least) does not like this script. Took awhile to figure this out, but as it turns out, IE for Mac requires that you include the actual submit button in the form. Go figure!
 
Thanks Shitmeister,

hats off to you :) You are really a great guy. You have created the account to post this solution and I have created this account to convey my thanks to u.

Thanks a lot buddy, I was searching like a mad for this solution and finally got it over here.

This reminds me old days of making web pages compatible to netscape 4.7, real headache it was :(

Hope to see u again guys.

3 cheers to Shitmeister......... hip hip hurray.... hip hip hurray.... hip hip hurray....
 
tonto said:
I have a problem,

I am trying to use the following vbscript to automatically submit a form. It works in IE but not in Mozilla. Does anyone have any suggestions on how to make this work?

<form name="frmUserCode" id="frmUserCode" method="POST" action="http://www.mysite.com/login.asp">
<input type="hidden" name="UCD" id="UCD" value="<% =str_UserCode % ">
</form>

<script type="text/vbscript" language="vbscript">
<!--
Document.GetElementByID("frmUserCode").Submit()
-->
</script>

I'm a bit late w/ this post, but hope it'll help someone.

this is for dividers <div> tags on the html page. but it can be used for forms too. i know i'm using a variant of it at work and it works for ie, mozilla, safari, netscape, so try it out.

try this

<script language="javascript">
var ns = document.layers;
var moz = document.getElementById && !document.all;
var ie = document.all;

function GetLayer(layerID)
{
if (ns)
return document.layers[layerID];
else if (moz)
return document.getElementById(layerID);
else if (ie)
return eval("document.all." + layerID);
else
return null;
}
</script>

my 2 cents :D
 
I'm running into the same problem. I have a .net page that has a small form and some javascript that calls a document.form.submit.

<form id="formID" method="post" runat="server">
<INPUT type="hidden" value="yes" name="AULI">
<INPUT type="hidden" value="T" name="TOIN">
<input type="hidden" name="IN" value="">
</form>

<script language=javascript>
document.forms(0).InquiryNumber.value = '<%=Request.QueryString["TN"]%>';
document.forms(0).action="www.somewhere.com";
document.forms(0).submit();

</script>

This page gets call and never submits (I've changed the variables and action for this post of course). My submit is in lowercase. It works fine in IE but not Firefox.
 
Heya,

the solution is in this...

dont name your submit button submit!!!
if you do...
when you call document.formname.submit()

it thinks your refering to the button and not the submit function!!!

Hope this helps :)
 
Devastated,

Holy crap......Thanks for the tidbit. I've been messing around with an auto-submitting form for three days now. Orginally I didn't have a submit button and the code worked fine...then I thought..."maybe I should put a submit button named "submit"", incase js is disabled. And guess what...no more workie.

Many thanks.
 
I have a similar issue...

I have some javascript that looks for the existance of an image file on a specific server, if the image is accessible, the script routes a form submission to the server with the existing image. If the image is not accessible, the form is submitted to an alternate server... a poorman's failover more or less.

Here's the code:

<HTML>
<BODY>
<SCRIPT language="JavaScript">
img = new Image();
img.src = 'http://192.168.0.200/status.gif';
img.onerror = function () {
document.write ("<HTML><TITLE>Secondary Submission</TITLE><HEAD>");
document.write ("<FORM method='post' action='http://192.168.1.200/cgi-bin/process.pl' name='secondary' id='secondary'>");
document.write ("<INPUT TYPE=hidden NAME='username' VALUE='%A'>");
document.write ("</FORM></HEAD></HTML>");
document.secondary.submit();
}
img.onload = function () {
document.write ("<HTML><TITLE>Primary Submission</TITLE><HEAD>");
document.write ("<FORM method='post' action='http://192.168.0.200/cgi-bin/process.pl' name='primary' id='primary'>");
document.write ("<INPUT TYPE=hidden NAME='username' VALUE='%A'>");
document.write ("</FORM></HEAD></HTML>");
document.primary.submit();
}
</SCRIPT>
</BODY>
</HTML>

This works in IE, but not Firefox...

UNTIL, I added:

document.write ("<INPUT TYPE=submit NAME='primary' VALUE='primary'>");

...for each code snipit, primary/secondary.

With the addition of the SUBMIT button, the code works, but I get a glimpse of the button before the script submits the data.

How can I make it so the button never appears? As mentioned before the code works fine without the TYPE=submit bit in IE... but not Firefox. I either need to hide the button (invisible), or make it so it's not required, like IE.

Any clues?

Thank you,
Dave
 
uberbandit said:
...
With the addition of the SUBMIT button, the code works, but I get a glimpse of the button before the script submits the data.

How can I make it so the button never appears? As mentioned before the code works fine without the TYPE=submit bit in IE... but not Firefox. I either need to hide the button (invisible), or make it so it's not required, like IE.

Any clues?

document.write ("<INPUT TYPE=submit NAME='primary' VALUE='primary' style='display:none'>");
 
Back
Top