Click here to Skip to main content
15,869,940 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
Hello everyone,

I have an .ascx(controller) and a javascript files.
THE SCENARIO:

When i click the checkbox it must show and hide other checkbox, and not only the checkbox but the label too. The fact is now i succeed to make it hide just the checkbox. And i need to make hide the label too.

here is the raw code from ascx file:
ASP.NET
<ItemTemplate>
 <li class="area">
   <input type="checkbox" class="category" value="<%# string.Concat(CurrentLocation.Area1,"| ", CurrentLocation.Area2)%>" />
   <label>                                      
     <%#CurrentLocation.Area2%>
   </label>
   <asp:Repeater ID="Repeater2" runat="server" DataSource="<%# GetThirdAreas(CurrentLocation.Area2) %>">
    <HeaderTemplate>
      <ul>
        </HeaderTemplate>
          <ItemTemplate>
            <li>
              <input type="checkbox" class="category" value="<%#string.Concat(CurrentLocation.Area1,"| ", CurrentLocation.Area2,"| ", CurrentLocation.Area3)%>" />
               <label>
                 <%#CurrentLocation.Area3%>
               </label>
            </li>
          </ItemTemplate>
          <FooterTemplate>
           </ul>
          </FooterTemplate>
   </asp:Repeater>
 </li>
</ItemTemplate>

And here is the javascript file:
JavaScript
function updateByArea(current) {
    //If current is unchecked => uncheck all child checkboxes
    if (current.attr("checked") == null || current.attr("checked") == "") 
        $j(".area ul li input [value^='" + current.val() + "']:checked").removeAttr("checked").hide(); //checkbox
    $j("#searchFilter .area>input:checkbox:checked").each(function (i, item) {
        $j(".area ul li input[value^='" + $j(item).val() + "']:not(:checked)").attr("checked", "checked").show();//checkbox
    });
}

THE QUESTION:

how i add the label to javascript code so when the user clicks the checkbiox and hides the checkbox to hide the label too?

Thank you in advance
Posted
Updated 25-Sep-12 21:46pm
v4

When you view the source of the generated HTML ,you'll not see a ID for the label and it will be rendered as just label with the text inside it.You need to provide a ID to it so that you can find the lable using jQuery and hide it.

$('label[id="id_val"]').hide();
 
Share this answer
 
Comments
willockss 25-Sep-12 3:06am    
I had give an ID to label.
i did like this:

<label id="last"></label>

and as jscript

$('label[id="id_val"]').hide();

And is still not hide the label
willockss 25-Sep-12 5:30am    
It worked like this

$('label[id="last_val"]').parent().hide();
willockss 26-Sep-12 3:28am    
Thank you so much sir for your help.
It worked like this:

JavaScript
$('label[id="last_val"]').parent().hide();


Thank you once again for the help
 
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