Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How do I use javascript arrays?

Posted on 2012-03-28
4
Medium Priority
?
384 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:Gurvinder Pal Singh
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

The top UI technologies you need to be aware of

An important part of the job as a front-end developer is to stay up to date and in contact with new tools, trends and workflows. That’s why you cannot miss this upcoming webinar to explore the latest trends in UI technologies!

Question has a verified solution.

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

This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
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…

715 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