0

I currently have a form as you will see below. For simplicity sake the form is condensed to the checkboxes that I'm working with. What I want to have happen is for a user to optionally click one or the other. Depending on which one is clicked, the other one should be disabled. I noticed that user "dinah" posted a similar question before and that this js fiddle was provided http://jsfiddle.net/A5TGf/19/ . However, for some reason when I applied my form id and switched the blacklist names around it wasn't working with my code. Any suggestions? Thanks

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&nbsp;&nbsp;&nbsp;</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>
4

1 回答 1

0

如果您需要通过 Javascript 禁用复选框,您只需要一行:

document.getElementById("foo").setAttribute("disabled","disabled")

并再次启用它,

document.getElementById("foo").removeAttribute("disabled")

我不认为你需要使用 jQuery 来完成这样的任务......

祝你好运!

于 2013-08-05T13:54:07.830 回答