Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

submit a form in netscape

Status
Not open for further replies.

ronsig

Programmer
May 24, 2001
54
IL
How do I submit a form in netscape?

If I have a file in the form of:
<html>
<head>
</head>
<body bgcolor=&quot;#000066&quot; text=&quot;#000000&quot;>
<form id = &quot;frm&quot; name=&quot;frm&quot; method=&quot;post&quot; action=&quot;someplace&quot; style=&quot;MARGIN-BOTTOM: 0px; MARGIN-TOP: 0px&quot; >
<input type = &quot;hidden&quot; id=&quot;Something&quot; VALUE=&quot;9&quot; >
<input type = &quot;hidden&quot; id = &quot;something else&quot; name=&quot;UserID&quot; VALUE= &quot;u99&quot;>
<input type=&quot;checkbox&quot; name=&quot;checkbox2&quot; >
</form>
</body>
</html>

and I want to submit it (not using a 'submit' button, but through a script callback function), how is it done? I've tried variations of window.document.frm.document.submit();
and window.document.getElementById(&quot;frm&quot;).submit();
and nothing happens

(I need to know how to do it in bith N4 and N6)

Thanks, Ron
 
User the following:

<script language=&quot;JavaScript&quot;><!--
function checkForm(frm){
if (frm.Name.value == ''){
alert('Need a Name..');
return false;
} else {
return true;
}
}
// <!--
</script>

<form name=&quot;frmGo&quot; action=&quot;gosomewhere.html&quot; onSubmit=&quot; return checkForm(this);&quot;>
<input type=&quot;text&quot; name=&quot;Name&quot;>
<input type=&quot;submit&quot; value=&quot;Go&quot;>
</form>


Should be what you are looking for...

Now the REAL challenge is to submit from a text link or image.
 
ronsig,

this works in ie and nn 4.7:

<html>
<head>
</head>
<body bgcolor=&quot;#000066&quot; text=&quot;#000000&quot;>
<form name=&quot;myform&quot; method=&quot;post&quot; action=&quot;someplace&quot; style=&quot;MARGIN-BOTTOM: 0px; MARGIN-TOP: 0px&quot; >
<input type=&quot;hidden&quot; id=&quot;Something&quot; VALUE=&quot;9&quot; >
<input type=&quot;hidden&quot; id = &quot;something else&quot; name=&quot;UserID&quot; VALUE= &quot;u99&quot;>
<input type=&quot;checkbox&quot; name=&quot;checkbox2&quot;>
<input type=&quot;button&quot; value=&quot;go!&quot; onClick=&quot;submit()&quot;>
</form>
</body>
</html> Hope it helps ;)

~ jsLove
 
Hi peeps,

It seems that I get the same problem before and I found the bug and fixed it.
My problem was the same with an action=&quot;javascript:window.close()&quot; of a form.
Now let me explain you why it didn't work.
This form was in a pop-up and it seems that NN doesn't recognize the form element in those pop-up until I put an hidden form in it.
After putting an hidden form, everything was ok.

Is your form in a pop-up?

Hope this helps...
 
Hey,

I'm working on a similiar problem and I have the exact same issue.

I have a form.submit() function on the onClick method of an <a> tag.

Under I.E. 5.5 and NS 4.7 (PC) it works.
Under Netscape 6.1 it seems to be working, but it's too soon to tell.
Under older browsers, Mac platform, etc, it wont submit the form. I.E. 5.0 wont submit the form either.

It's bug city. Check this out:

If I move the code to an OnMouseOver event, it works fine all the time.
If I move the code to an OnClick for a button object, it works fine all the time.

It's a problem with form.submit(), <a> and lots of browsers. It's been the most frustrating problem i've ever had.

I can post the code, if you'd like. I have no current solution short of re-writing the whole damned program.

-b
 
This script works on NS6, important is the id Attribut in the Form Tag, otherwise the function getElementById couldn't get the Form Object.

<script>
function SetOkCode(FormName)
{
FObject = document.getElementById(FormName);

FObject.submit();
}

<FORM name=&quot;PersonalData&quot; id=&quot;PersonalData&quot; method=post action=&quot;...
<a href=&quot;javascript:SetOkCode('PersonalData')&quot;>Test Submit</a>
</form>

Have a lot fun with the bugggiest Browser........
 
Hi Burton I have the same problem. Could you send me please the code.

at cdelforge@sddc.fr
 
The .submit() method doesn't seem very reliable in most browsers. The easiest workaround is to have a button, hide it, then get your code to click the button for you:

<html>
<head>
</head>
<body bgcolor=&quot;#000066&quot; text=&quot;#000000&quot;>
<form id = &quot;frm&quot; name=&quot;frm&quot; method=&quot;post&quot; action=&quot;someplace&quot; style=&quot;MARGIN-BOTTOM: 0px; MARGIN-TOP: 0px&quot; >
<input type = &quot;hidden&quot; id=&quot;Something&quot; VALUE=&quot;9&quot; >
<input type = &quot;hidden&quot; id = &quot;something else&quot; name=&quot;UserID&quot; VALUE= &quot;u99&quot;>
<input type=&quot;checkbox&quot; name=&quot;checkbox2&quot; >
<input type=&quot;submit&quot; id=&quot;btSubmit' name='btSubmit' value='whatever' style='visibility: hidden' >
</form>
<script language=&quot;JavaScript&quot;>
btSubmit.click();
</script>
</body>
</html>

mentor@innocent.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top