Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Auto open accordian in asp.net

Posted on 2013-06-24
6
Medium Priority
?
366 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

OverviewThis article demonstrates a simple search form using AJAX. The purpose of the article is to demonstrate how to use the same code to render a page and javascript (JQuery) and AJAX to make subsequent calls to refine the results. The princip…
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 …
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…
Suggested Courses

926 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