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

Form will not submit unless I include an alert

Status
Not open for further replies.

LarrySteele

Programmer
May 18, 2004
318
0
0
US
I'm having an odd JavaScript problem. I've searched Google and this forum, but have not found a solution.

Code:
function next_page() {
    document.forms["frm_post"].submit();
}
From what I can see, this should submit the form. It does not.

However, with this small change, the form will submit:
Code:
function next_page() {
    document.forms["frm_post"].submit();
    [COLOR=red]alert("submit the form already");[/color]
}

In the modified function, the alert flashes, goes away (read: not modal), and the form posts.

Any suggestions on what would cause this strange behavior?

TIA,
Larry
 
When is this being triggered?
What is its context within the page?
Have you checked you have no errors?


----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Web & Tech
 
Phil, thanks for asking. While I was away, I finally bumped into the answer:
What I did was change my static hidden form elements visible. When I landed on the page, they were where I expected them to be. Then I triggered and ajax call and suddenly form elements went clear. That sent me looking for why an ajax call would trigger a page reload/refresh.

All I had to do was modify my button's onclick event from "next_page();" to "next_page(); return false;". After that, no more page reload/refresh and now the page moves forward.

Now that I have that working, I can move forward with this project. But, I also see I have some more studying to do to understand the effect of the [tt]return[/tt] clause here and why it had the effect it did.

Thanks again,
Larry
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top