Solved

Auto open accordian in asp.net

Posted on 2013-06-24
6
345 Views
Last Modified: 2013-10-15
I have an asp/ajax accordion on my page. What I would like to do is have it open and close automatically and loop through. I did find a script that will change the selected index (this works fine)

 <script type="text/javascript">
         function pageLoad() {
             changeSelected(1);
         }

         // expand given accordion pane
         function changeSelected(idx) {
             $find('Accordion1_AccordionExtender').set_SelectedIndex(idx);
         }
    </script>

Is it possible to modify this script to... lets say every 30 seconds, open the next unselected index and so on until it's get to the end, then start over at 0?

Thanks for any help.
0
Comment
Question by:someonenamedbrendan
  • 4
  • 2
6 Comments
 
LVL 14

Expert Comment

by:dejaanbu
ID: 39274129
just an idea:

if you are sure about the number of panes, ...say 5

(UNTESTED CODE)

var idx=0;
changeSelected(); //for initial select

setInterval(changeSelected,30000);

 function changeSelected() {
if(idx>4) {  idx =0;}
             $find('Accordion1_AccordionExtender').set_SelectedIndex(idx); idx++;
         }
0
 

Author Comment

by:someonenamedbrendan
ID: 39274915
thanks. I'll try it and see if I can make it work... but I never know how many panes I'm going to have.
0
 
LVL 14

Expert Comment

by:dejaanbu
ID: 39276971
getting the count is easyy:

add  a server side function (C#)

 public int getCount(){
           return MyAccordion.Panes.Count();
       }

in js,

add one more variable for storing the count first;

var totalPanes = <%= getCount()%>;
var idx=0;
changeSelected(); //for initial select

setInterval(changeSelected,30000);

 function changeSelected() {
if(idx>totalPanes ) {  idx =0;}
             $find('Accordion1_AccordionExtender').set_SelectedIndex(idx); idx++;
         }
0
Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

 

Author Comment

by:someonenamedbrendan
ID: 39278151
thanks. I'll try it.
0
 

Accepted Solution

by:
someonenamedbrendan earned 0 total points
ID: 39563293
I ended up using the timer control
0
 

Author Closing Comment

by:someonenamedbrendan
ID: 39573134
because it was the answer.
0

Featured Post

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question