Solved

How do I use javascript arrays?

Posted on 2012-03-28
4
378 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Industry Leaders: 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!

Question has a verified solution.

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

JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
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…

752 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