Solved

How do I use javascript arrays?

Posted on 2012-03-28
4
376 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 Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
C# Windows app updating JSON file error. 9 39
orderby list (from Json) 1 29
modify change color of text 9 35
How do I Enable submit button only if listbox has items 4 30
Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
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…

756 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