Anton
Anton

Reputation: 429

Performs form action even out of the form

Hi having a problem with this code even if i clicked on cancel it will still proceed to use the action of my form even though the CANCEL button is not part of the form, Would appreciate any help.

Here is the code.

      <form method="post" action="input_enroll.php" >
            <div id="overlay1">

                <div>
                    <h1> Enter Educational Level Entry</h1>
                <input type="text" name="level" >
            <input type="submit"   value="Proceed To Enroll" '>
                    </form>
                <input type="submit"   value="Cancel" onclick='overlay()'>
                </div>
            </div>

EDIT: Any suggestions what would be a better idea? I'm thinking putting the cancel outside the div.

Upvotes: 1

Views: 51

Answers (1)

Rajat Singhal
Rajat Singhal

Reputation: 11264

You are having form started, then divs started, then form closed..start form after divs..

as your markup is not correct, browsers will change it as thier parser suggest,

In chrome </form> tag is postponed after </div>s..

        <div id="overlay1">
            <div>
            <form method="post" action="input_enroll.php" >
                <h1> Enter Educational Level Entry</h1>
                <input type="text" name="level" />
                <input type="submit"   value="Proceed To Enroll" />
            </form>
            <input type="submit" value="Cancel" onclick='overlay()' />
            </div>
        </div>

Upvotes: 1

Related Questions