Link to home
Create AccountLog in
Avatar of DotNetChano
DotNetChanoFlag for United States of America

asked on

Cant figure out how to make CHeckboxlist Item cause collapsible panel to open

I have tried everything and cant figure this out. I have collapsible panels setup on this page. If I attach the collapse to a button they work fine. So far I cant find a way to attach them to an item in my checkbox list

ie
I have 3 checkboxes in my list: checkbox a, checkbox b, checkbox c

When any or all of them are selected I would like their corresponding panel to open up. When they are deselected I would like the panel to close.

Trying to accomplish this without codebehind if possible
Avatar of Julian Hansen
Julian Hansen
Flag of South Africa image

Trying to accomplish this without codebehind if possible

Codebehind is not the way to go.

Without seeing how you have implemented your page it is difficult to say how to proceed.

Coding this in Javascript is pretty straight forward.

Using JQuery it would be something like

<script type="text/javascript">
$(function() {
   $('#checkbox-list input[type="checkbox"]').click(function() {
       $('#' + $(this).data('panel')).toggle();
   });
});
</script>
// HTML
<div id="checkbox-list">
  <input type="checkbox" value="1" data-panel="panel1" /> Panel1 <br/>
  <input type="checkbox" value="2" data-panel="panel2" /> Panel2 <br/>
  <input type="checkbox" value="3" data-panel="panel3" /> Panel3 <br/>
</div>
<div id="panel1">
  <p>panel1</p>
</div>
<div id="panel2">
  <p>panel2</p>
</div>
<div id="panel3">
  <p>panel3</p>
</div>

Open in new window

Avatar of DotNetChano

ASKER

I could do it that way if there is no way to do it solely with ajax. Does anyone know the settings I could use with the collapsiblepanelextender and checkboxlist to accomplish this?

thank you for your response either way!
You can do it with AJAX - but why would you want to??
Sorry for abrupt response - seriously though - is there any particular reason why you would want to do this with AJAX?
I appreciate the abruptness so no reason to apologize. Its not so much that I care about this particular thing being done with ajax. I more or less am trying to learn how to find the controlid of a listitem just for my own knowledge.
ASKER CERTIFIED SOLUTION
Avatar of Julian Hansen
Julian Hansen
Flag of South Africa image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer