Click here to Skip to main content
15,887,585 members
Home / Discussions / JavaScript
   

JavaScript

 
AnswerRe: attr disabled property is not working for FF Pin
Graham Breach12-Feb-12 22:46
Graham Breach12-Feb-12 22:46 
AnswerRe: attr disabled property is not working for FF Pin
Mohibur Rashid14-Feb-12 5:53
professionalMohibur Rashid14-Feb-12 5:53 
GeneralRe: attr disabled property is not working for FF Pin
ramuAlla1-Mar-12 1:15
ramuAlla1-Mar-12 1:15 
AnswerRe: attr disabled property is not working for FF Pin
Ed Nutting19-Feb-12 0:34
Ed Nutting19-Feb-12 0:34 
QuestionHow can i use backbone.js Pin
DeepthiTanguturi10-Feb-12 22:02
DeepthiTanguturi10-Feb-12 22:02 
AnswerRe: How can i use backbone.js Pin
Richard MacCutchan10-Feb-12 23:50
mveRichard MacCutchan10-Feb-12 23:50 
Questionpage loading Pin
Member 79044828-Feb-12 20:22
Member 79044828-Feb-12 20:22 
QuestionNeed Help Setting <img> src attribute Pin
PianoMan7-Feb-12 5:26
PianoMan7-Feb-12 5:26 
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
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional/EN" "http://www.w3.org/TR/html4/loose.dtd">
<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">
<h2>Javascript and Images</h2>

<div id="parentDiv">

<p>
Trying to set the image source with js...
</p>

<div id="childDiv">

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

</div>

<div id="vTableContainer"></div>

</div>
</body>
</html>

AnswerRe: Need Help Setting src attribute Pin
Dean Oliver7-Feb-12 6:40
Dean Oliver7-Feb-12 6:40 
GeneralRe: Need Help Setting src attribute Pin
PianoMan7-Feb-12 16:24
PianoMan7-Feb-12 16:24 
GeneralRe: Need Help Setting src attribute Pin
Dean Oliver7-Feb-12 21:56
Dean Oliver7-Feb-12 21:56 
AnswerRe: Need Help Setting src attribute Pin
Mohibur Rashid7-Feb-12 18:12
professionalMohibur Rashid7-Feb-12 18:12 
AnswerRe: Need Help Setting src attribute Pin
twseitex19-Feb-12 2:50
twseitex19-Feb-12 2:50 
QuestionImages Won't display in IE 7 Pin
PianoMan5-Feb-12 6:27
PianoMan5-Feb-12 6:27 
AnswerRe: Images Won't display in IE 7 Pin
Richard MacCutchan5-Feb-12 23:23
mveRichard MacCutchan5-Feb-12 23:23 
GeneralRe: Images Won't display in IE 7 Pin
PianoMan6-Feb-12 4:15
PianoMan6-Feb-12 4:15 
GeneralRe: Images Won't display in IE 7 Pin
Richard MacCutchan6-Feb-12 4:30
mveRichard MacCutchan6-Feb-12 4:30 
GeneralRe: Images Won't display in IE 7 - SOLVED Pin
PianoMan6-Feb-12 4:43
PianoMan6-Feb-12 4:43 
GeneralRe: Images Won't display in IE 7 - SOLVED Pin
Richard MacCutchan6-Feb-12 5:31
mveRichard MacCutchan6-Feb-12 5:31 
AnswerRe: Images Won't display in IE 7 Pin
jsc4214-Feb-12 3:41
professionaljsc4214-Feb-12 3:41 
AnswerRe: Images Won't display in IE 7 Pin
twseitex19-Feb-12 2:59
twseitex19-Feb-12 2:59 
QuestionProblem with args.isValid in JS Pin
dayakar_dn1-Feb-12 22:14
dayakar_dn1-Feb-12 22:14 
AnswerRe: Problem with args.isValid in JS Pin
Mohibur Rashid1-Feb-12 22:36
professionalMohibur Rashid1-Feb-12 22:36 
GeneralRe: Problem with args.isValid in JS Pin
dayakar_dn1-Feb-12 23:03
dayakar_dn1-Feb-12 23:03 
GeneralRe: Problem with args.isValid in JS Pin
Mohibur Rashid1-Feb-12 23:10
professionalMohibur Rashid1-Feb-12 23:10 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.