Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

why is this happening

0 views
Skip to first unread message

Willyam Pax

unread,
Jul 11, 2008, 2:06:59 AM7/11/08
to

im just a beginner in javascript i just want to kown why is this happening?

[object HTMLImageElement] Introduction


[object HTMLImageElement] Schedule


[object HTMLImageElement] Speaker

im trying to put the image into an array with this code

var myEvent2 = new Array("Introduction","Schedule","Speaker");
bullet[0]= new Object();
bullet[0].picture="image2/bullet.jpg";

for(t=0;t<myEvent2.length;t++){

b[t]=new Image();
b[t].src=bullet[0].picture;
//document.body.appendChild(b[t]);

p[t]=document.createElement("p");
p[t].innerHTML ="&nbsp;&nbsp;&nbsp;"+myEvent2[t];
//document.body.appendChild(p[t]);

g[t]=b[t]+"&nbsp;&nbsp;&nbsp;"+myEvent2[t]+"<br>";

p2[t]=document.createElement("p");
p2[t].innerHTML =g[t];
document.body.appendChild(p2[t])
}


Anthony Jones

unread,
Jul 11, 2008, 3:21:37 AM7/11/08
to
"Willyam Pax" <wil...@activediscovery.net> wrote in message
news:%230ZaTwx...@TK2MSFTNGP05.phx.gbl...

b[t] = new Image();

Creates a new image element.

g[t]=b[t]+"&nbsp;&nbsp;&nbsp;"+myEvent2[t]+"<br>";

You are now asking JScript to peform a string concatenation and include the
image element object as an item to concatenate. JScript calls the objects
.toString() method to retrieve a string representation of the object. In
most cases this would be the sort of string you are seeing [object
HTMLImageElement.

Try this:-

var myEvent2 =new Array("Introduction", "Schedule", "Speaker");

for (var i=0; i < myEvent2.length; i++)
{
var p = document.body.appendChild(document.createElement("p"));
var img = p.appendChild(document.createElement("img"));
img.src ="image2/bullet.jpg";
img.style.marginRight = "3ex";
p.appendChild(document.createTextNode(myEvent2[i]));
}


--
Anthony Jones - MVP ASP/ASP.NET


Willyam Pax

unread,
Jul 11, 2008, 4:46:00 AM7/11/08
to
wow thanks
it indeed help me...
"Anthony Jones" <A...@yadayadayada.com> wrote in message
news:ON9$Cby4IH...@TK2MSFTNGP05.phx.gbl...
0 new messages