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
 
Hi ronsig,

The best way to do this is the following:
document.frm.submit() It works on both IE and NS.

Gtz,

Kristof
 
I've tried the following in both N4 and N6 and nothing happens!

<html>
<head>
<script language=&quot;javascript&quot;>
function su()
{
document.frm.submit();
}
</script>
</head>
<body>
<form method=&quot;post&quot; action=&quot;mailto:myemailaddress&quot; id =&quot;frm&quot; name =&quot;musicForm&quot;>
<input type=&quot;button&quot; name=&quot;checkbox2&quot; onclick= &quot;document.frm.submit();&quot;></input>
</form>
</body>
</html>

In fact, in N4 I got a javascript error saying that &quot;document.frm has no properties&quot;
 
Hi ronsig,

The id isn't necessary, use the name.
In this case it would be:

document.musicForm.submit()

Gtz,

Kristof
 
I've etried it the way you described:
<html>
<head>
<script language=&quot;javascript&quot;>
function su()
{
document.frm.submit();
}
</script>
</head>
<body>
<form method=&quot;post&quot; action=&quot;mailto:my_email&quot; name =&quot;frm&quot;>
<input type=&quot;button&quot; name=&quot;submit&quot; value = &quot;submit&quot; onclick= &quot;su();&quot;></input>
</form>
</body>
</html>

runs in IE but NOT in Netscape (neither in N6 and N4)
Did it work when you tried running in netscape?
 
Hi,

The problem is that you haved named your button submit. Which is a JS function. Thus, the browser gets confused and returns an error. The answer is to use a name like this one: btSubmit

Don't know if a mailto as action for a form works.

Gtz,

Kristof
 
I've tried renaming- nada!
I know 'mailto:' works in IE for forms.
 
hie guyz
ronsig, may be document.forms.frm.submit() or document.forms[&quot;frm&quot;].submit() wuld help?

regards, vic
 
Hi all,

I've tested it like this and it worked.
But then you can't run any scripts.

Code:
<form method=&quot;post&quot; action=&quot;mailto:my_email&quot; name =&quot;frm&quot;> 
	<input type=&quot;submit&quot; name=&quot;sub&quot; value=&quot;Submit&quot;>
</form>

An other posibility is the following:

Code:
<html> 
<head> 
<script language=&quot;javascript&quot;>
function su()
{
	document.location.href=&quot;mailto:my_email&quot;
}
</script>
</head> 
<body> 
<form method=&quot;post&quot; action=&quot;&quot; name =&quot;frm&quot;> 
	<input type=&quot;button&quot; name=&quot;submit&quot; value = &quot;submit&quot; onclick= &quot;su();&quot;>
</form> 
</body> 
</html>

Gtz,

Kristof
 
Hi!

The first way is the &quot;usual way&quot; to submit (and I'm looking for a way to do it from a function, without the user having to press a button)

The second is very original, but unfortunately, it just opens the mail program. Even in IE this behaves differently from the way my original example works.

Surely, netscape does allow submitting a form SOMEHOW?! (not using a submit button)
 
kristof, like u told,
the other possibility doesnt work as long as button named submit; i checked it out & got that if u'll rename button somehow it wuld work perfectly both in ie & nn..
ronsig, never use reserved words as variables, names or function names, if u dont want thus a big pain..

regards, vic
 
no help there!

I don't know what you mean by &quot;work perfectly both in ie & nn&quot;, since neither way does the simple task of submitting a form from a function
(as I've said already, the second way kristoff suggested opens the mail program, I need it to send the form's data directly, including collection of the variables in the form). The name issue is resolved already, no need to delve on it!
 
oops, sorry, i was lasy 2 read carefully kristoff's last post.. X-)

what i mean is:
function su(){ document.frm.submit(); }

<form name=&quot;frm&quot; >
<input type=&quot;button&quot; name=&quot;trsubmit&quot; value = &quot;submit&quot; onclick= &quot;su()&quot;>
</form>


works for me..
 
Hi all,

I proposed my two sollutions because NS for some unknown (and to me, quite incomprehensable) reason just didn't submit. And, even stranger, I didn't get any error messages!

I asked a collegue of mine who is more experienced in JS than me and he also couldn't grasp why this occurs.

PS: I must have copied the button code from one of the previous post without noticing it. ;-)

This reminds me why i'm really starting to dislike coding for NS.

Gtz,

Kristof
 
Yeah, me too!
BTW, in addition to not showing any error messages, once the browser gets snagged on that line, it stops execution of the script in question altogether!
 
so,guyz, problem is solved?
or netscrap still dont submit for'ya?

regards, vic B-)
 
problem is definitely NOT solved!
As written above - netscape only submits if a 'submit' button is pressed in the form. I absolutely must find a way to submit from a script!
 
well, dont kno what is on ur guyz machines, but my windoze get it 2 work
looks like it doesnt handle &quot;submit&quot; event, 'coz when i wrote smth like <form name=frm onsubmit=&quot;alert('submited')&quot; action='doit.cgi?blahblah'> there was no messagebox, but, at least it tryes 2 connect 2 the action's program (cryes that netscrap cant find it..), so, it might be workin, but VERY weirdly..
 
I've used just onClick=&quot;form.submit()&quot; and it works fine in IE5.5 and NS4.7. Tracy Dryden
tracy@bydisn.com

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top