2011-03-24 79 views
0

我希望當用戶檢查我的複選框時它不會再出現。 但是我的腳本正在運行,所以當腳本第二次運行時,即使用戶沒有選中我的複選框,它也不會顯示。我的所有網頁都通過ajax。getChecked()== true不起作用

if (!in_array('checked', $_SESSION["questy"])) 
     { 
      ?> 
<div id="fifty" style="width:150px; height:25px; float:right" > 
<input class="bigcheck" type="checkbox" id="cb" onclick="hiding()"/> 
<span style="color:#FFF;font-size:20px;font-family:Arial, Helvetica, sans-serif;font-weight:lighter;">50/50</span> 
</div> 
<?php }?> 
function hiding(){ 

document.getElementById('<?php echo $ran1;?>').setStyle({"display":"none"}); 
document.getElementById('<?php echo $ran2;?>').setStyle({"display":"none"}); 
document.getElementById('fifty').setStyle({"display":"none"}); 
var c=document.getElementById('cb').getChecked(); 
alert(c); 


if(document.getElementById('cb').getChecked()== true) 
{ 

<?php 
$_SESSION["questy"][] = 'checked'; 
?> 
} 

} 
+0

function fnShowProps(obj)var result =「」; for(var i in obj) result + = i +「=」+ obj [i] +「\ n」; alert(result); } 嘗試fnShowProps(document.getElementById('cb'))。可能會幫助你解決你的問題。 (document.getElementById('cb')。getChecked()== true) – 2011-03-24 12:26:01

回答

0

您正在混淆服務器端PHP和客戶端Javascript。這是行不通的。 全部 PHP在頁面發送到瀏覽器之前執行。

您應該做的是使用Ajax將已更改的情況提交給服務器,以便它可以在新頁面中處理服務器端;或者在提交表單後處理它(服務器端)。

+0

if this be executedatedif(012)。 ?> } – 2011-03-24 12:19:49

相關問題