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

submit() does not work in IE5 . 1

Status
Not open for further replies.

lsyhu

Programmer
Apr 27, 2002
12
US
Hi, guys,

I met a strange problem. I have some hyper links. When user clicks them, it will call some javascript function (see code below). That function assigns values to some hidden fields, and then call the form's submit() method. It works well in IE6, but the submit() does not work in IE5.5 and IE5. No error message, it just does not run submit() at all. I tracked the code before and even after the submit(), they all work OK.

<!-- hyper link-->
<A HREF=&quot;#&quot; onClick=&quot;gotoPag(document.Searchdb, 'page', '1', 'table','Project')&quot;>
Status of Project
</A>

<!-- java script function -->
function gotoPage (aForm, hidden1, val1, hidden2, val2)
{
aForm[hidden1].value = val1;
aForm[hidden2].value = val2;
aForm.submit(); //Does not run. No error message.
return ;
}



I have another button on the screen. On click, it will call a different java script function (see code below). And the submit() in this function works.

<!-- button -->
<INPUT TYPE=button NAME=unFilterBtn VALUE=&quot;Reset&quot; class=&quot;Bsbttn&quot; onClick=&quot;doFilter(document.Searchdb, 'filterHdn', 'no')&quot;>

<!-- javaScript function -- >
function doFilter (aForm, aHidden, aValue)
{
aForm[aHidden].value = aValue;
aForm.submit(); //works
return;
}



Is this a browser problem? Is there any way I can make it work in IE5 and IE5.5?

Thanks.

Lisa
 
Technically you should use document.formname instead of just formname in your code. I don't know if this is the problem or not, but that's the only thing I can spot offhand.
Tracy Dryden
tracy@bydisn.com

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard. [dragon]
 
not sure...
have u done an alert right after the function begins to see whether it is being called or not?
something like..
function gotoPage (aForm, hidden1, val1, hidden2, val2)
{
alert(&quot;IT GETS CALLED!&quot;);
...
your code..
...
}

Use this to see is the msgbox comes up or not.. Lyra Computing
 
Thanks, guys.

I solved the problem.


I changed the hyper link from
<!-- hyper link-->
<A HREF=&quot;#&quot; onClick=&quot;gotoPag(document.Searchdb, 'page', '1', 'table','Project')&quot;>
Status of Project
</A>


to
!-- hyper link-->
<A HREF=&quot;javascript:gotoPag(document.Searchdb, 'page', '1', 'table','Project')&quot;>
Status of Project
</A>

Then it works well.

Have a good weekend.
Lisa
 
I would never have guessed that that could cause the problem you mentioned.
Tracy Dryden
tracy@bydisn.com

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard. [dragon]
 
Weird - I know that I have done this in the past but cannot get it to work on IE5 for myself:( What you need to do is first replace the <a href=&quot;#&quot; with <a href=&quot;javascript:void(0);&quot;> since #, the anchor is a valid url within a page.
Also make sure that the script is within the head of the page. Let me know if this works for you!

Pat
 
There is one thing that should be pointed out. If you are using href=&quot;#&quot; you should also use return false in the onclick. The reason for this is that a simple # is a valid url but sends you to the top of the page. return false in the onclick stops the browser from sending you to the top of the page.

<a href=&quot;#&quot; onclick=&quot;myFunction('params'); return false;&quot;>do something</a>

Just though I would mention this. :) Gary Haran
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top