If method=“get” gave an error, then you can try method=“post”. I don’t know too much about javascript. All of my forms to date have made calls to CGI scripts. If you need help with Perl or PHP, I’m your boy. And since I bring it up, it seems likely that the search is being done by a CGI script or something along those lines. Why not forgo the javascript entirely, and simply pass the search parameter from the FORM directly to the script? I imagine you don’t want every Tom, Dick and Harry having the URL in question, but if you can post it, it might help for us to see it.
enipla
Modify your form tag to this:
<FORM name="frmSearch" onSubmit="legalpre(); return false">
onSubmit is an event handler, and several of the event handlers have special uses of return values – although there does not appear to be a consistent rhyme or reason for them.
The onSubmit event handler generally defaults to a request to submit the form (using a normal submission method). Since you are trying to override the normal submission and just call a javascript function instead, use the “return false” clause (at the end of the event handler’s code) to prevent the form from actually being “submitted”.
Thanks Monstre & Q.E.D
The solution was a combo of your answers.
<FORM name=“frmSearch” onSubmit=“legalpre(); return false” method=“get”>
Thanks again
enipla - Alpine
You’re quite welcome
Actually, you shouldn’t even need the ‘method=“get”’ part, since the “return false” clause means that you are preventing the form submission itself.
I tested it without any method or action attributes, and it worked well. Thanks to NotMrKnowItAll for making the test files easy to set up (and enipla, I did put in your change that initially “broke” it, too – so I was able to replicate the problem exactly as you had described it).
I’ll bet anything this is actually an issue of context. The definition of “parent” changes depending on where the function is called from. If you call from onSubmit “parent” probably references something different from calling it from onClick. The function IS being called in both cases.
Incidentally, rather than doing this:
onSubmit=“whatever(); return false”
I like to do this:
onSubmit=“return whatever();”
and I make sure my function returns false (or true, or what have you.) I just find it easier to read.