Solved

How do I use javascript arrays?

Posted on 2012-03-28
4
373 Views
Last Modified: 2012-04-03
Hi,

I have the below javascript set against the div id "homepagecarousel" containing two images on my page...

<script type="text/javascript">
var carouselContent = new Array("<i>Welcome to our new website...</i>", "<i>Hello world...</i>");
      function hasMoved(m) {
        $("#topBannerStatement").html("<p>" + carouselContent[m.current] + "</p>");
      }
      
      $(function(){
        $('#homepagecarousel ul').moodular({ auto: true,callbacks: [hasMoved],api: true, dispTimeout:3000} );
        //Below line removed to allow the home page rotating banner to hold the above carouselContent text, all other pages use the General template
        $("#topBannerStatement").html("<p>" + carouselContent[0] + "</p>");
      });
    </script>

Open in new window


The div containing the images looks like...

<div id="homepagecarousel">
              <ul>
                  <li><img src="/media/17458/websites_merge.jpg" width="626px" height="334" /></li>
                  <li><img src="/media/17453/animated_merge.jpg" width="626px" height="334" /></li>
              </ul>
          </div>

Open in new window


How can I alter the javascript so I can pin a certain array item to a specific image?

Thanks.
0
Comment
Question by:aspnet-scotland
  • 2
4 Comments
 
LVL 20

Expert Comment

by:BuggyCoder
ID: 37776248
$('#homepagecarousel').find('img').map(function(){
                       return $('this').html='';
                   })

Open in new window

0
 
LVL 40

Expert Comment

by:gurvinder372
ID: 37776252
<<How can I alter the javascript so I can pin a certain array item to a specific image?>>
Didn't get you.

If you want to check which index you are currently on and then apply certain settings accordingly, then override the move method
http://www.gougouzian.fr/projects/jquery/moodular/

in the new move method, check for the current index of the item and then apply whatever settings you want to apply

you will have to do this on run time only. Looking at the documentation, i don't think you can specify such things when moodular is initialized
0
 

Accepted Solution

by:
aspnet-scotland earned 0 total points
ID: 37777367
I fixed this by simply adding:

$("#topBannerStatement").html("<p>" + carouselContent[1] + "</p>");

below line 10 of my code.

Thanks anyway.
0
 

Author Closing Comment

by:aspnet-scotland
ID: 37799971
Solved myself
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
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…

947 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now