1
希望有人可以幫我用我的代碼。我正在使用重寫的URL並在窗體上放置了這段代碼。當頁面第一次加載mypage.htm時,默認情況下,type_24複選框被選中。如果他們檢查type_12框,我想type_24框取消選中。PHP複選框和URL重寫
我的問題是,如果我檢查type_12框,頁面刷新和type_12和type_24框被檢查..這不是我想要的。我認爲這是因爲我在我的操作中重新加載了我的重寫URL,因爲它工作正常,如果我只是將php文件作爲操作。
任何想法如何我可以修復我的代碼,以便它只有檢查type_24時檢查type_12?
<form name="frmrefresh" id="frmrefresh" method="post" action="mypage.htm">
<input type="checkbox" name="type_12" id="type_12" <?php if(isset($_POST['type_12']) && $_POST['type_12']=="12"){?> checked="checked"<?php }?> value="12" onClick="uncheck24(this);" /> <label>12</label>
<input type="checkbox" name="type_24" id="type_24" <?php if(isset($_GET['id']) && $_GET['id']!=''){?>checked="checked"<?php }?><?php if(isset($_POST['month_24']) && $_POST['type_24']=="24"){?> checked="checked"<?php }?> value="24" onClick="uncheck12(this);"/> <label>24 Months</label>
<input type="hidden" name="id" value="<?php echo $_REQUEST['id'];?>" />
</form>
在標題中,我有以下功能:
function uncheck12(obj)
{
if (obj.checked == true)
{
document.getElementById("type_12").checked = false;
document.frmrefresh.submit();
}
}
function uncheck24(obj)
{
if (obj.checked == true)
{
document.getElementById("type_24").checked = false;
document.frmrefresh.submit();
}
}
約翰你好,非常感謝你的幫助。但一個問題,當頁面刷新,和我做這種檢查\t \t \t \t 如果(isset($ _ REQUEST [ 'type_24'])&& $ _REQUEST [ 'type_24'] == '24'),它仍然認爲type_24仍然檢查,即使在屏幕上它看起來沒有選中?任何想法爲什麼?謝謝! – gatin 2012-02-26 14:02:01
你能否澄清你的意思是'它仍然認爲type_24仍然被檢查'?你在哪裏以及如何看到這個? – John 2012-02-26 19:40:06