2009-09-11 108 views
-2

我有一個textarea和一個按鈕的窗體。如果在textarea爲空時單擊該按鈕,表單將重新加載並生成錯誤消息。否則,表單將重定向到另一個頁面。現在,我集成了一個jQuery對話框。當按鈕被點擊時,對話框應該出現並詢問是或否的問題。問題是當我點擊按鈕時出現對話框,但幾秒鐘後消失。我怎樣才能解決這個問題?我使用php的窗體和jQuery的對話框。爲什麼我的jquery對話框在幾秒鐘後消失?

ps。在PHP中,當你點擊表單中的按鈕時,頁面將重新加載正確?我認爲這與盒子的消失有關,因爲它在重新加載之前就消失了。

這裏是我的代碼

<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> 
+0

代碼PLZ沒有這將很難猜測... – IProblemFactory 2009-09-11 22:09:31

+0

Flavius是正確的,必須使用返回false;我只是想添加一些東西 - 你說「在PHP中,當你點擊表單中的按鈕時,頁面將重新加載正確的?」 PHP只是服務器端。沒有像PHP表單或PHP按鈕那樣的東西。他們是HTML元素。這只是因爲你的行爲爲$ PHP_SELF,它指向相同的頁面(只需看看瀏覽器中的html源代碼來驗證) – 2009-09-12 04:59:18

+0

我放置onclick =「myRedirect();」在我的提交按鈕和onsubmit =「什麼();」在我的窗體中,但對話框仍然消失。點擊對話框中的按鈕後,如何將頁面重定向到某個頁面? – noob 2009-09-12 05:55:21

回答

0

爲了保持形式從提交,你需要在它的onsubmit事件一個「返回false」。

相關問題