Forum Moderators: coopster
I created a form that is inside my php code so that It will pull information and email it upon request.
On my other form I used simple java to have a window pop-up to confirm the request was entered, but I get an error when i try to add the java to my form-
echo "<form method=\"get\" name=\"subscription\" action=\"../Mail.php\">";
here is what i have with plain HTML:
<form method="get" name="subscription" action="javascript:poptastic('../Mail.php');">
I'm sure it something simple...
<form method="get" name="subscription" action="javascript:poptastic('../Mail.php');">
Javascript is not a URL. Javascript is not a URL. Javascript is not a URL.
And if JS is disabled, your form is now is broken. You want to do two things here:
In "poptastic" add return false to the very end of the routine. Change your form action like so:
<form method="get" name="subscription" action="/Mail.php" onSubmit="return poptastic('/Mail.php');">
function poptastic(url) {
// whatever it does, then
return false;
}
What this does is passes the submit to poptastic() without submitting the form. It's the return false that does this for you. If JS is disabled, the form will still submit. Best of both worlds.
Another thing, don't get in this habit: ../Mail.php
One day you will find yourself doing this
../../../../Mail.php
Always use a leading slash. /Mail.php. This means "start at document root" and will work in various conditions. If you ever mess with mod_rewrite, sometimes "this URL" is not really "where you are" and this will save you.