PHP/Javascript: Restart Form Button Isn't Working, Code Insde
<p>Basically I want a confirmation box to pop up when they click the button asking if they sure they want to restart, if yes, then it destroys session and takes them to the first page. Heres what i got...</p>

<pre><code>echo "&lt;form id=\"form\" name=\"form\" method=\"post\" action=\"nextpage.php\"&gt;\n";
echo "  &lt;input type=\"button\" name='restart' value='Restart' id='restart'
        onclick='restartForm()' /&gt;";
</code></pre>

<p>and for the script...</p>

<pre><code>&lt;script type=\"text/javascript\"&gt;
     &lt;!--
    function restartForm() {
    var answer = confirm('Are you sure you want to start over?');
    if (answer) {
        form.action=\"firstpage.php\";
        session_destroy();
        form.submit();
    } else
        alert ('Restart Cancelled');
    }
    // --
&lt;/script&gt;";
</code></pre>

<p>EDIT: Note that pressing the button brings up the confirm box, but if you click okay nothing happens sometimes. Sometimes if u click cancel it still submits the form (To the original action)</p>
