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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

document.form.submit() - microsoft is working vs netscape isn't

Status
Not open for further replies.

mdclarke

MIS
Nov 3, 2000
9
CA
hi,

I have a form that uses external (non-form) buttons to submit and reset.
It is working in IE and failing in Navigator.
The call to the subroutine is working in both (the verification edits work in both) but the execution of document.form.submit() & document.form.reset() fails in Netscape.

Any ideas?

Thanks
Mike Clarke

//Validate the user name and password for presence.

function ValLogin(User,Pass)
{
if (User == "")
{
alert("Please Enter A User Name");
document.LoginF.UserID.focus();
return false;
}
else if (Pass == "")
{
alert("Please Enter A Password");
document.LoginF.Password.focus();
return false;
}
else
{
document.LoginF.submit();
return true;
}

}


<snip>

<form NAME=&quot;LoginF&quot; ACTION=&quot;LoginVal.ASP&quot; METHOD=&quot;POST&quot;>
<tr>
<td><input TYPE=&quot;text&quot; SIZE=&quot;20&quot; Name=&quot;UserID&quot;></td></font>
</tr>
<tr><td><input TYPE=&quot;Password&quot; SIZE=&quot;20&quot; Name=&quot;Password&quot;></td>
</tr>
</form>

<tr>
<td><a href=&quot;#&quot; onClick=&quot;return ValLogin(document.LoginF.UserID.value,document.LoginF.Password.value)&quot; onmouseover=&quot;changeImage('submit','but5h')&quot; onmouseout=&quot;changeImage('submit','but5')&quot;>
<IMG src=&quot;images/SubmitB.gif&quot; width=&quot;60&quot; height=&quot;30&quot;border=&quot;0&quot; name=&quot;submit&quot; alt=&quot;Submit Login&quot;></a></td>

<td><a href=&quot;#&quot; onclick=&quot;document.LoginF.reset()&quot; onmouseover=&quot;changeImage('reset','but6h')&quot; onmouseout=&quot;changeImage('reset','but6')&quot;><IMG src=&quot;images/ResetB.gif&quot; width=&quot;60&quot; height=&quot;30&quot;border=&quot;0&quot; name=&quot;reset&quot; alt=&quot;Reset Login&quot;></a></td>
</tr>
 
The best way to do it is to put the onsubmit function on the form. You don't need an anchor round an image just put <input type=&quot;image&quot; src=&quot;../img/blah.gif&quot;> and it will automatically become the submit button. Regards

Big Dave

davidbyng@hotmail.com


** If I am wrong I am sorry, but i'm only trying to help!! **

 
Well,
It's a bit of a hybrid....
I used the input and image suggestion with a onSubmit handler to take care of the validation and submit and gave up on the reset().
Using a function to do it's easier on my nerves.

I did loose the button's image switch, it's not picking up on the image name that's needed in the onmouseover/out events.

MClarke


<form NAME=&quot;LoginF&quot; ACTION=&quot;LoginVal.ASP&quot; METHOD=&quot;POST&quot; onSubmit=&quot;return ValLogin(document.LoginF.UserID.value,document.LoginF.Password.value)&quot;>
<tr>
<td><p><b>User Name</b></td>
<td><input TYPE=&quot;text&quot; SIZE=&quot;20&quot; Name=&quot;UserID&quot;></td>
</tr>
<tr>
<td><b>Password:</b></td>
<td><input TYPE=&quot;Password&quot; SIZE=&quot;20&quot; Name=&quot;Password&quot;></td>
</tr>
<tr>
<td><input type=&quot;image&quot; src=&quot;images/SubmitB.gif&quot; width=&quot;60&quot; height=&quot;30&quot; border=&quot;0&quot; name=&quot;submit&quot; alt=&quot;Submit Login&quot; onmouseover=&quot;changeImage('submit','but5h')&quot; onmouseout=&quot;changeImage('submit','but5')&quot;></td>
</form>
<td><a href=&quot;#&quot; onClick=&quot;ResetLogin()&quot; onmouseover=&quot;changeImage('reset','but6h')&quot; onmouseout=&quot;changeImage('reset','but6')&quot;><IMG src=&quot;images/ResetB.gif&quot; width=&quot;60&quot; height=&quot;30&quot; border=&quot;0&quot; name=&quot;reset&quot; alt=&quot;Reset Login&quot;></a></td>
</tr>
 
Try changing your image name from &quot;submit&quot; to something else. There seems to be a problem when you have a button named &quot;submit&quot;, I suspect and image of the same name might cause the same problem.

In short: NEVER use a reserved word for a name! Tracy Dryden
tracy@bydisn.com

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard.
 
Hi,

Good point, didn't work but I take the point anyway.
I think it has more to do with the submit button (now named submitb) shifting from href/img to type.
But it's late and it will wait.

MC
 
First I do not have Netscape here but you can try this:
The form tag has got a name, try to give it an ID as well like so:
<form NAME=&quot;LoginF&quot; ID=&quot;LoginF&quot; ....
If this does not work you can try the eval function (I beleve it works with both netscape and IE) but try to give each object (textfield, button, image, form etc...) an ID as well as a name like in the form tag sample above.
You can try my adjusted code of your code, here it is:
<script>
function ValLogin(){
if (eval(&quot;LoginF.Usr&quot;).value == &quot;&quot;)
{
alert(&quot;Please Enter A User Name&quot;);
eval(&quot;LoginF.Usr&quot;).focus();
}
else if (eval(&quot;LoginF.passw&quot;).value == &quot;&quot;)
{
alert(&quot;Please Enter A Password&quot;);
eval(&quot;LoginF.passw&quot;).focus();
}
else
{
eval(&quot;LoginF&quot;).submit();
}

}
</script>
<form NAME=&quot;LoginF&quot; id=&quot;LoginF&quot; ACTION=&quot;LoginVal.ASP&quot; METHOD=&quot;POST&quot;>
<tr>
<td><input TYPE=&quot;text&quot; SIZE=&quot;20&quot; Name=&quot;Usr&quot; id=&quot;Usr&quot;></td>
</tr>
<tr><td><input TYPE=&quot;Password&quot; SIZE=&quot;20&quot; Name=&quot;passw&quot; id=&quot;passw&quot;></td>
</tr>
</form>

<img src=&quot;myimg.gif&quot; onClick=&quot;ValLogin();&quot;>
<img src=&quot;reset.gif&quot; onClick=&quot;eval('LoginF').reset();&quot;>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top