2014-02-21 55 views
1

我想在我的網頁中使用對話框。我有一個記錄集返回一個電子郵件地址。如果記錄集是空的,jquery會打開對話框嗎?

我希望僅在記錄集爲空時打開對話框。

這是腳本,以便票價

<script> 
$(document).ready(function() { 
    $(function() { 
    $("#dialog-message").dialog({ 
     modal: true, 
    autoOpen: false, 
     buttons: { 
     Ok: function() { 
      $(this).dialog("close"); 
     } 
     } 
    }); 
    }); 
    }); 
    </script> 


<div id="body"> 

<% If Email.EOF And Email.BOF Then %> 

<div id="dialog-message" title="Error No Email address found"> 
       <p><span class="ui-icon ui-icon-circle-check" style="float:left; margin:0 7px 50px 0;"></span> Error, you don't have an email address linked to your account. </p> 
       <p> You cannot request this report</b>. </p> 
      </div> 

<% End If ' end Email.EOF And Email.BOF %> 

</body> 

任何幫助將是巨大的..... PS。 ..我在Dreamweaver中做這個(所以noob)...

+0

你能描述您遇到的問題?對話框是否打開,即使有電子郵件,你是否永遠不會收到電子郵件,對話框是否永遠不會打開,還有其他的東西? – hassassin

+0

我在開始時使用的代碼是正確的,發現當沒有電子郵件地址實際上是一個空格時,而不是NULL被傳回,而我正在檢查Null's。更新了所有電子郵件地址NULL和它的作品完美, 是破壞我的頭。 – raymantle

+0

@ user3339240嗨,歡迎來到SO。我很高興你找到了你的問題的答案,你可以把它作爲答案張貼並標記爲已接受(請參閱[我可以回答我自己的問題嗎?](http://stackoverflow.com/help/self-answer) )。這種做法是積極鼓勵,這意味着這個問題不會顯示在未答覆的列表中。 – Lankymart

回答

0

上述工作正常。它沒有爲我工作的原因是因爲我的SQL腳本返回結果,當我期望它什麼都不返回。

當什麼都沒有返回時,我的If語句正常工作。

這完全

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%> 
<% 
Dim Recordset2 
Dim Recordset2_cmd 
Dim Recordset2_numRows 

Set Recordset2_cmd = Server.CreateObject ("ADODB.Command") 
Recordset2_cmd.ActiveConnection = MM_----------_STRING 
Recordset2_cmd.CommandText = "SELECT Email FROM dbo.tblusers WHERE UserName = ? AND Email <> ''" 
Recordset2_cmd.Prepared = true 
Recordset2_cmd.Parameters.Append Recordset2_cmd.CreateParameter("param1", 200, 1, 50, Recordset2__varusername) ' adVarChar 

Set Recordset2 = Recordset2_cmd.Execute 
Recordset2_numRows = 0 
%> 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head runat="server"> 
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> 
<link rel="shortcut icon" href="../favicon.ico" > 
<link rel="icon" type="image/gif" href="../animated_favicon1.gif" > 
<title>-------------------</title> 

<script> 
    $(function() { 
    $("#dialog-message").dialog({ 
     modal: true, 
     minWidth: 400, 
     closeOnEscape: false, 
     my: "center", 
     at: "center", 
     of: "#targetElement", 
     buttons: 
     { 'Go Back': function() { 
     document.location = '/HeadOffice/HeadOfficeMenu.asp'; 
    }, 

     } 
    }); 
    }); 
    </script> 
<body> 
<header> 
     <div class="content-wrapper"> 
      <div class="float-left"> 
       <p class="site-title"> 
        ---------- </p> 
      </div> 

</header> 
    <div id="body"> 
     <asp:ContentPlaceHolder runat="server" ID="FeaturedContent" /> 

     <section class="content-wrapper main-content clear-fix"> 
      <asp:ContentPlaceHolder runat="server" ID="MainContent" /> 
      <table width="200" border="1"> 
    <tr> 
    <td><input type="button" onClick="history.go(-1)" value="Back" class="noprint" /></td> 
<td>&nbsp;</td> 
    </tr> 
</table> 
      <p>This Request will be proccessed nightly and emailed.</p> 
      <% If Recordset2.EOF And Recordset2.BOF Then %> 
      <div id="dialog-message" title="Error No Email address found"> 
       <p> Error, you don't have an email address linked to your account.<br /> 
Please contact ---------------------------- and request to have your email added. </p> 
       <p> You cannot request this report. </p> 
      </div> 
      <% End If ' end Recordset2.EOF And Recordset2.BOF %> 

     </section> 
    </div> 

<footer> 
     <div class="content-wrapper"> 
      <div class="float-left"> 
       <p>------------------ 
       </p> 
      </div> 
     </div> 
</footer> 

</body> 
</html> 
<% 
Recordset2.Close() 
Set Recordset2 = Nothing 
%>