Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET Javascript HTML C#4.0 , +
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:
<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:
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 24-Sep-12 4:51am
Edited 25-Sep-12 21:46pm
v4
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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();
  Permalink  
Comments
willockss at 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 at 25-Sep-12 5:30am
   
It worked like this
 
$('label[id="last_val"]').parent().hide();
willockss at 26-Sep-12 3:28am
   
Thank you so much sir for your help.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

It worked like this:
 
$('label[id="last_val"]').parent().hide();
 
Thank you once again for the help
  Permalink  

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 339
1 Nirav Prabtani 248
2 OriginalGriff 234
3 _Amy 165
4 Maciej Los 145
0 OriginalGriff 7,744
1 Sergey Alexandrovich Kryukov 6,956
2 Maciej Los 3,994
3 Peter Leow 3,708
4 CHill60 2,742


Advertise | Privacy | Mobile
Web03 | 2.8.140721.1 | Last Updated 26 Sep 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100