Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
P

PianoMan

@PianoMan
About
Posts
5
Topics
2
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Need Help Setting <img> src attribute
    P PianoMan

    Dean, Thanks for the reply. I've been working with the jquery api just a bit today, and I really like it. Thanks for the reference!

    JavaScript javascript html data-structures testing beta-testing

  • Need Help Setting <img> src attribute
    P PianoMan

    I've hit a wall trying to use javascript to write a table with some image tags. I'm looping through an array of image names, then setting their src attribute. The function is creating the tags, but all that displays is the 'missing image' thumbnail. The function is fired via a button. Below is my code. Thanks!

    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta name="robots" content="noindex">

    <title>Testing Javascript</title>

    <script type="text/javascript">

    function getImages() {

    // Declare variables
    var allImages, vRow, vCell, vText, vImg;
    var vCnt, i, j, x, y;
    var vTable = document.createElement("TABLE");
    var vTBody = document.createElement("TBODY");

    // Insert vBody into vTable
    vTable.appendChild(vTBody);

    // create an array
    var images = new Array();

    images[0] = "image1.jpg";
    images[1] = "image2.jpg";
    images[2] = "image3.jpg";

    // count values in the array
    vCnt = images.length;

    // loop through the array of images and answers
    for (i=0; i < vCnt; i++)
    {
    // create a row
    vRow = document.createElement("TR");

    // create a TD tag
    vCell = document.createElement("TD");
    
    // create IMG element
    var image = images\[i\];
    vImg = document.createElement("IMG");
    vImg.setAttribute("src", "images/" + image);
    
    // insert the img tag into the td tag
    vCell.appendChild(vImg);
    
    // insert the cell into the row
    vRow.appendChild(vCell);
    
    // insert the row into the table
    vTBody.appendChild(vRow);
    

    }

    // add the table to the doc
    var vTableContainer = document.getElementById("vTableContainer");
    vTableContainer.appendChild(vTable);
    }
    // end updatePage()
    </script>
    </head>

    <body bgcolor = "#FFFFFF">

    Javascript and Images

    Trying to set the image source with js...

    <form method="GET">
    <input type="button" value="DISPLAY IMAGES" onClick="getImages();" />
    </form>

    </body>
    </html>

    JavaScript javascript html data-structures testing beta-testing

  • Images Won't display in IE 7
    P PianoMan

    Thanks for the reply. Well, I removed the javascript from the HTML page and put it in a js file, and now it works. Go figure... Thanks a lot, Microsoft. :(

    JavaScript javascript html data-structures tools question

  • Images Won't display in IE 7
    P PianoMan

    Thanks for the reply, however that did not fix this problem. The IE browser does display the little thumbnail box, which tells me the image tag is there, but this line of code vImg.src = images[i]; for some reason is not setting the source for the image. I've even tried hard coding in the source with no luck.

    JavaScript javascript html data-structures tools question

  • Images Won't display in IE 7
    P PianoMan

    Would someone please tell me why this js won't display images in IE 7, but works perfectly in Firefox? I'm using Windows XP, and I've double-checked all my settings in IE 7. Thanks!

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <HTML>
    <HEAD>
    <TITLE>Sample</TITLE>

    <SCRIPT LANGUAGE="JavaScript">
    window.onload = fnWrite;

    function fnWrite()
    {
    // Declare variables
    var vTable = document.createElement("TABLE");
    var vTBody = document.createElement("TBODY");
    var vRow, vCell, vDiv, vImg;
    var i;

    var images = new Array();
    images[0] = "images/treble_f1.JPG";
    images[1] = "images/treble_c1.JPG";
    images[2] = "images/treble_d1.JPG";
    images[3] = "images/treble_e1.JPG";

    // Insert vBody into vTable
    vTable.appendChild(vTBody);

    // Insert a row
    vRow = document.createElement("TR");
    vTBody.appendChild(vRow);
    vCell = document.createElement("TD");
    vRow.appendChild(vCell);

    // Insert images
    for (i=0; i<images.length; i++)
    {
    vDiv = document.createElement("DIV");
    vCell.appendChild(vDiv);

    vImg = document.createElement("IMG");
    vImg.src = images\[i\];
    vImg.setAttribute("alt", "image");
    vCell.appendChild(vImg);
    

    }
    // Insert the table
    vTableContainer.appendChild(vTable);
    }
    </SCRIPT>

    </HEAD>
    <BODY>
    <H1>Javascript Won't Work in IE 7</H1>
    <div id="vTableContainer"></div>

    </BODY>
    </HTML>

    JavaScript javascript html data-structures tools question
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups