tags:

views:

651

answers:

1

i have a form with a textarea and a button. if the button is clicked while the textarea is empty, the form will reload and generate an error message. otherwise, the form will redirect to another page. now, i integrated a jquery dialog box. when the button is clicked the dialog box should appear and ask a yes or no question. the problem is when i click the button the dialog box appears but disappears after a few seconds. how can i fix this? i'm using php for the form and jquery for the dialog box.

ps. in php, when you click a button in a form the page will reload right? i think this has something to do with the disappearing of the box because it disappears right before it reloads.

here's my code

    <form id="form1" name="form1" method="post" action="<? echo $PHP_SELF; ?>" enctype="multipart/form-data" onsubmit="myRedirect();">
          <p class="style16">
          <div align="left">

            <p><span class="style5">Rules:</span>
            <?    
      if($_POST['continue']) {
       if($_POST['rules']==null) {
        echo $_SESSION['nature']."<font color='red' size='3'><b>Please enter the rules.</b></font><br>";
       }
      }
      ?>
              <input type="hidden" name="other_id" value="<? echo $_SESSION['other_id']; ?>">
          <input type="hidden" name="hidden1" value="<? echo $_SESSION['hidden1']; ?>">
            </p>

            <p>
              <textarea name="rules" rows="7" cols="49"></textarea>

              <br />
            </p>
            <div id="dialog" title="Empty the recycle bin?">
    <p><span class="ui-icon ui-icon-alert" style="float:left; margin:0 7px 20px 0;"></span>Is the judge/speaker/facilitator from UST?</p>
</div>
            <p><input type="submit" name="continue" id="continue" value="Continue"/>
            <input type="reset" name="clear" value="Clear"></p>
              <center>


    <!--<input type="submit" name="clear2" id="clear2" value="Clear" onClick="textfield.value="" textfield2.value="" textarea.value="" textarea2.value="" 

    textarea3.value="" textarea4.value="" textarea5.value="" textarea6.value="" file.value="" "/>-->
                  </center>
                </p>
              </div>
              </form>
+1  A: 

To keep the form from submitting, you need a "return false" in its onsubmit event.

Flavius Stef