Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9243895
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T08:54:29+00:00 2026-06-18T08:54:29+00:00

I wish to pass an array to a function(can you tell me if im

  • 0

I wish to pass an array to a function(can you tell me if im on the right track?)

and then in the function I wish to loop through the values in an array and append each one into the following LI element in HTML

This is what I have so far a user will code in the URL values he wants to pass:

var arrValues = ['http://imgur.com/gallery/L4CmrUt', 'http://imgur.com/gallery/VQEsGHz'];
calculate_image(arrValues);

function calculate_image(arrValues) {
    // Loop over each value in the array.
    var jList = $('.thumb').find('href');
    $.each(arrValues, function(intIndex, objValue) {
        // Create a new LI HTML element out of the
        // current value (in the iteration) and then
        // add this value to the list.
        jList.append($(+ objValue +));
    });
}
}

HTML

<li>
    <a class="thumb" href="" title="Title #13"><img src="" alt="Title #13" /></a>
    <div class="caption">
        <div class="download">
            <a href="">Download Original</a>
        </div>
        <div class="image-title">Title #13</div>
        <div class="image-desc">Description</div>
    </div>
</li>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T08:54:30+00:00Added an answer on June 18, 2026 at 8:54 am

    If you’d like to pass in an array, simply put it in as a parameter. In Javascript, you can pass numbers, strings, arrays, objects, and even functions in as parameters.

    See this example for a thumbnail builder implementation: http://jsfiddle.net/turiyag/RxHys/9/

    First, define the arrays.

    var bluearray = [
        'http://fc02.deviantart.net/fs30/f/2008/056/8/0/Purple_hair___Bipasha_Basu_by_mstrueblue.jpg',
        'http://static.becomegorgeous.com/img/arts/2010/Feb/20/1805/purple_hair_color.jpg',
        'http://img204.imageshack.us/img204/6916/celenapurpleqp7.jpg'
        ];
    var greenarray = [
        'http://25.media.tumblr.com/tumblr_m7fqmkNEhc1qlfspwo1_400.jpg',
        'http://www.haircolorsideas.com/wp-content/uploads/2010/12/green-red-hair.jpg',
        'http://fc02.deviantart.net/fs71/i/2010/011/9/c/Neon_Yellow_and_Green_Hair_by_CandyAcidHair.jpg'
        ];
    

    Then when the DOM is loaded, call the functions to load the thumbnails.

    $(function() {
        addThumbs(bluearray);
        addThumbs2(greenarray);
    });
    

    addThumbs uses jQuery’s each function to make things a bit cleaner. I find it looks better and is nicer to use that the normal Javascript for loop.

    function addThumbs(paths) {
        $.each(paths,function(index, value) {
            $("div").append('<img src="' + value + '" />');
        });
    }
    

    But if you’re a fan of native Javascript, the normal for loop is implemented in addThumbs2

    function addThumbs2(paths) {
        for(index in paths) {
            $("div").append('<img src="' + paths[index] + '" />');
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I pass associative array in the below code. I dont wish to
I want to pass a string array (separated by commas), then use a function
I have a function that loops through a multidimensional array that consists of the
How can I pass an array of filenames into the following method: public static
I wish to pass values of the selected items into a database and however
hello i am very confused on how to properly pass an array through functions
I wish to pass FromDate and ToDate into a procedure and then update and
I am using Ajax.BeginForm and wish to pass in parameters to the function called
Afternoon, I wish to pass the row number of a table to a function
I wish to pass a variable to a function and have the function select

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.