Solved

How do I use javascript arrays?

Posted on 2012-03-28
4
372 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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
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…

706 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

22 Experts available now in Live!

Get 1:1 Help Now