Jump to content

return from function???


mickeymouse

Recommended Posts

Shouldn't this code return me to my from and not take action to open the next program/file.

     function formcheck(myform)

     {alert('Form Check.');    return false;}

with the following form parameters:

     <form name='AmendForm' action='FT_AmendUpdate.php' method='POST' onsubmit='return formcheck(AmendForm)'>

Whether I use return true or return false, the submit displays the "Form Check" message and then opens 

the next program/file: FT_AmendUpdate.php

Link to comment
Share on other sites

Shouldn't the traditional way still work.

Depends on what the browser vendors decide to do.  I don't believe that method is part of the standard, so when you're talking about non-standard things you'll find that they work differently in different browsers.  That will work in older browsers, sure.  It might not work on mobile devices though, for example.

https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault

Note that those examples also attach the listener using addEventListener rather than using event attributes.

Link to comment
Share on other sites

It works perfectly on my other forms so it's not a browser related problem.

I'll look at the link you gave me in more detail later but right now I would prefer to find the problem and fix it rather than venture into new stuff at this time.

As I said, it works in my other forms so I don't see why it shouldn't work in this one.

Thanks for your help and thanks for moving the item to Javascript - I keep thinking these functions I've coded are PHP - sorry about that.

 

Link to comment
Share on other sites

Sounds like you've got an error stopping the other code from running.  Make sure to check the console in your browser's developer tools.  It might be the variable AmendForm, it doesn't look like it's defined.  Pass this instead to pass the element where you have the attribute.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...