2012-08-03 72 views
0

如何使用PHP編寫的聲明進行警報框彈出?我已經打算現在就使這項工作警報(模態窗口)框聲明

的JS代碼是這樣的:

$(".bAlert").click(function() { 
    jAlert('This is a custom alert box. Title and this text can be easily editted', 'Alert Dialog Sample'); 
}); 

該代碼使用它的一個按鈕時能正常工作,但我希望它顯示出來,當本聲明進入玩:

if ($operation == "divide") { 
    $answer = $number1/$number2; 
    $operation = "÷"; 
} else { 
    $output = "CODE TO MAKE THIS WORK HAS TO GO HERE"; 
} 

這是它是如何工作的一個按鈕:

<input type="button" value="Usual alert" class="basicBtn mr10 ml10 bAlert" /> 

回答

0

只是把它放在第e else語句

if ($operation == "divide"): 
    $answer = $number1/$number2; 
    $operation = "&#247;"; 
else: 
    echo "<script>jAlert('This is a custom alert box. Title and this text can be easily editted', 'Alert Dialog Sample');</script>"; 
    endif; 
+0

除非該php已經位於某些腳本標記中,否則您可能需要將其封裝在腳本標記中,對嗎? – Jeemusu 2012-08-03 02:28:02

+1

我不認爲'.click()'處理程序是需要的,至少我的印象是OP只是想直接調用'jAlert()'。 – nnnnnn 2012-08-03 02:34:38

+0

是啊不知道我在想什麼...更新了代碼。 – Kris 2012-08-03 02:47:50