Results 1 to 6 of 6

Thread: JavaScript to count number of images

  1. #1
    Join Date
    Nov 2009

    JavaScript to count number of images

    I have certain queries in my JavaScript project. There will be multiple images on my form. These will be selected by the user on the form prior to this form. When the user comes on this form of images it should display how many images are present in the current form. So the user is not needed to count his/her selection. I am unable to code this.

  2. #2
    Join Date
    Oct 2005

    Re: JavaScript to count number of images

    Images Object Array is supported in JavaScript 1.1 version of JavaScript. The Image Object Array is a collection of all the images in a document. To determine the total number of images displayed in the document we need to use the length property. Thus if you need to count the number of images using JavaScript use the length property of Image Object Array.

  3. #3
    Join Date
    Apr 2008

    Image Object for Images

    In JavaScript we can deal with images in a document using JavaScript Image Object. The basic syntax to access the image using the image object is:
    To access image relative to its location in an array:
    Using Image name to access the image:
    To get the image count

  4. #4
    Join Date
    Apr 2008

    document.images.length to count image

    I too had to keep a track of the image count in my JScript project where the images resembled the choices made by the visitor and I had to tally them all at the end. I tried many things and finally this piece of code helped me to get the image count:
    <script language="JavaScript1.1">
    Include the above code in your project to enable image count in a document. You may print or save the image count to be used later.

  5. #5
    Join Date
    Feb 2008

    JavaScript for HTML

        <img src="Tiger.gif">
        <img src="Cat.gif">
        <img src="Lion.gif">
    <script language="JavaScript">
        document.write(document.images.length," Images");
    This piece of code helped me to track the number of images in my file using the scripting language as JavaScript with HTML web page. Hope this will work for you as well.

  6. #6
    Join Date
    May 2008

    counting images in JavaScript

    I had an assignment question where in it was required to a count of images on a web page which was to be scripted using JavaScript. We were given two images on a document and had to count them to display the image count as 2. This is the program that I did:
    <img alt="Virus" border="0" src="Pic1.gif" width="70" height="70" />
    <br />
    <img alt="Worm" border="0" src="Pic2.gif" width="50" height="50" />
    <br /><br />
    <script type="text/javascript">
    document.write("The image count of this document is: " + document.images.length);

Similar Threads

  1. How to count number of characters in Excel
    By Bankebihari in forum Windows Software
    Replies: 6
    Last Post: 15-05-2012, 05:52 PM
  2. PHP - Count number of words
    By GlassFish in forum Software Development
    Replies: 3
    Last Post: 27-11-2009, 01:19 PM
  3. Count the number of times yes appears in a range in excel
    By Andy Candy in forum Windows Software
    Replies: 3
    Last Post: 17-08-2009, 01:33 PM
  4. How to count number of words automatically?
    By Basaam in forum Windows Software
    Replies: 4
    Last Post: 25-04-2009, 11:00 PM
  5. How To Count The Number Of Characters?
    By Harsh01 in forum Software Development
    Replies: 2
    Last Post: 13-02-2009, 12:25 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts