0
我目前有一個表格,您將在下面看到。爲了簡單起見,表單被壓縮到我正在使用的複選框。我想要發生的事情是用戶可以選擇單擊一個或另一個。根據點擊哪一個,另一個應該被禁用。我注意到用戶「dinah」在之前發佈了類似的問題,並且提供了這個js小提琴http://jsfiddle.net/A5TGf/19/。但是,由於某種原因,當我申請我的表單ID並且在其周圍切換了黑名單名稱時,它並未與我的代碼一起工作。有什麼建議麼?由於需要關於禁用複選框的幫助
HTML/PHP
<form name="insertTicket" id="insertTicket" action="index.php" method="POST" >
<div id="ticket_hidden" style="text-align: center; clear:both;">
<div id="visible_div" style="float: left;">
<input type="checkbox" name="escalated" id ="escalated" value="Yes" onclick="doInput(this);" tabindex="18">Escalate
</div>
<div id="hidden_div" style="float: left; display:none;">
<?php
$dept = $_SESSION['dept_id'];
$get_email = mysql_query("Select email_name, dept_id, copy_user from emails where escalated = 'yes'");
while(($email = mysql_fetch_assoc($get_email)))
{
$department = explode(",", $email['dept_id']);
if(in_array($dept, $department, TRUE))
{
echo '
<input type="checkbox" name="escalated_to[]" id="escalated_to[]" value="'.$email['email_name'].'" />'.$email['email_name'].'
';
if($email['copy_user'] == 'YES')
{
echo '
<input type="text" name="emails[]" style="width: 175px; height: 20px;" placeholder="To:">
';
}
}
}
?>
</div>
<div id="visible_divX" style="float: left;">
<input type="checkbox" name="email" id="email" value="Yes" onclick="doInputs(this);" tabindex="20">Send Email </div></td></tr>
<div id="hidden_divX" style="float: left; display:none; ">
<?php
$dept = $_SESSION['dept_id'];
$get_email = mysql_query("Select email_name, dept_id, copy_user from emails where escalated != 'yes'");
while(($email = mysql_fetch_assoc($get_email)))
{
$department = explode(",", $email['dept_id']);
if(in_array($dept, $department, TRUE))
{
echo '
<input type="checkbox" name="emailed_to[]" id="emailed_to[]" value="'.$email['email_name'].'" />'.$email['email_name'].'
';
if($email['copy_user'] == 'YES')
{
echo '
<input type="text" name="emails[]" style="width: 175px; height: 20px;" placeholder="To:">
';
}
}
}
?>
</div>
</form>
我目前使用JS來隱藏/顯示另外兩個div字段。不確定這是否是可能導致問題的原因。 –
你使用jQuery嗎?實際處理顯示/隱藏部分的JS代碼在哪裏? – Maximus2012
我認爲通過jQuery來做它會容易得多。看到這個和類似的答案:http://stackoverflow.com/questions/4935819/jquery-disable-all-checkboxes-apart-from-current-one – Maximus2012