Click here to Skip to main content
15,899,124 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello everyone,
I have searched and tried many different "solutions" but none have worked out yet for me. I am using JQuery and JQuery UI. I have several rows in a form and at the start of each row I have a check box that, once checked, enables the rest of the elements within that row. The problem is that the check box doesn't enable the radio set or the input box that I have.

If I convert the check box to just a button, it works great, but not as a check box. Here is my JQuery code:
Java
$( ".Account" ).attr('disabled', 'disabled').button('refresh');

$("#InputAD").click(function() {
   var jq = $("#InputADID, #InputADAction1, #InputADAction2, #InputADAction3,);
					
   if (jq.filter(":disabled").length)
      jq.removeAttr('disabled').button('refresh');
   else
      jq.attr('disabled', 'disabled').button('refresh');
   return false;
});


Now for the HTML code that DOES work:
HTML
<button id="InputAD" name="InputAD"><label for="InputAD">Active Directory</label>

<input type="text" id="InputADID" name="InputADID" placeholder="Username" maxlength="50" class="Account">

<input type="radio" id="InputADAction1" name="InputADAction" checked="checked" class="Account"/><label for="InputADAction1">Add Account</label>

<input type="radio" id="InputADAction2" name="InputADAction" class="Account" /><label for="InputADAction2">Modify Account</label>

<input type="radio" id="InputADAction3" name="InputADAction" class="Account" /><label for="InputADAction3">Already Done</label>


The problem is that I really need to have a check box rather then a button to start each row (for visual reasons and for the way my ASP works). If I put in the following code instead of the button line it doesn't work. The check box highlights just fine, but doesn't enable the rest of the row:

HTML
<input type="checkbox" id="InputAD" name"=InputAD" /><label for="InputAD">Active Directory</label>


Any ideas on what I'm doing wrong or other ways to handle this?
Posted

1 solution

It seems that you have one typo mistake on the name of the checkbox you have written name"=InputAD" . It should be name="InputAD"

I have following code in my machine and it is working I used IE7.

XML
<input type="checkbox" id="InputAD" name="InputAD" />
    <label for="InputAD">
        Active Directory</label>
    <input type="text" id="InputADID" name="InputADID" placeholder="Username" maxlength="50"
        class="Account" />
    <input type="radio" id="InputADAction1" name="InputADAction" checked="checked" class="Account" /><label
        for="InputADAction1">Add Account</label>
    <input type="radio" id="InputADAction2" name="InputADAction" class="Account" /><label
        for="InputADAction2">Modify Account</label>
    <input type="radio" id="InputADAction3" name="InputADAction" class="Account" /><label
        for="InputADAction3">Already Done</label>



JavaScript
$(function(){
    //by default keep everything in disabled mode.
    $(".Account").attr("disabled","disabled");
    $("#InputAD").click(function (e){//debugger;
        if(this.disabled)
        {
            $(".Account").attr("disabled","disabled");
        }else {
            $(".Account").removeAttr("disabled");
        }
    });
});
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900