473,473 Members | 1,805 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

appendChild with custom objects

Firstly, thanks for all the help in here.

My code is:

<script type="text/javascript">
var img1= new Image(200,200)
img1.src="file://d:/datatools/c++/boat1.jpg"
var img2 = new Image(200,200)
img2.src="file://d:/datatools/c++/china1.jpg"

function art(title,program,dated,author,url){
this.title=title;
this.program=program;
this.dated=dated
this.author=author;
this.url=url;
}
var show1=new art("the boat", "photoshop", "Aug 2004", "Shawn
Modersohn", img1)
var show2=new art("China", "photoshop", "Aug 2004", "Pamela Phillips", img2)
function navigateTo(){
var newElem=document.createElement("P")
newElem.appendChild(show1.url)
document.getElementById("rightI").appendChild(newE lem)
}
</script>

It is going to be a script that cycles images for a slideshow
presentation. I am not worrying quite yet about the if elses, the for
loops, and other such control structures.

What I want to know is how I can append both an image coupled with the
title etc. As I am sure most of you are aware, appendChild(show1.url +
show1.title) does not work. I am hoping to use css and declare #rightI
p img {block} and other such attributes to control presentation. I just
want to know how to get both the image and the title, author, etc, into
the div I want them to go in. As it is now, it works only well enough
to append the appropriate image. Thanks again for any help.

Jul 23 '05 #1
1 1713


Shawn Modersohn wrote:

<script type="text/javascript">
var img1= new Image(200,200)
img1.src="file://d:/datatools/c++/boat1.jpg"
var img2 = new Image(200,200)
img2.src="file://d:/datatools/c++/china1.jpg"

function art(title,program,dated,author,url){
this.title=title;
this.program=program;
this.dated=dated
this.author=author;
this.url=url;
}
var show1=new art("the boat", "photoshop", "Aug 2004", "Shawn
Modersohn", img1)
var show2=new art("China", "photoshop", "Aug 2004", "Pamela Phillips",
img2)
function navigateTo(){
var newElem=document.createElement("P")


Well create what you need an append it e.g.
var img = document.createElement('img');
img.src = show1.src;
img.title = show1.title;
img.alt = ''
newElem.appendChild(img);

If you also want to display text then create a text node and append that too
var text = document.createTextNode(show1.dated);
newElem.appendChild(text);

--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 23 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Neil Zanella | last post by:
Hello, In Python, classes are objects. But there is no way to custom print a class object. This would require some syntax such as the one commented out below: With the current "foo =...
25
by: kie | last post by:
hello, i have a table that creates and deletes rows dynamically using createElement, appendChild, removeChild. when i have added the required amount of rows and input my data, i would like to...
1
by: Nicolas Van Lancker | last post by:
Hi folks; I have this webpage, allowing users to insert multiple records in one post into the database. Because I don't know the exact number of records they want to add, I created a little...
2
by: samuel.adam | last post by:
Hi all, I am coding an AJAX DHTML whatever application and I was fed up with always typing a lot of appendChild() functions. I created a custom one called append_children() and wanted to share...
1
by: ryanmhuc | last post by:
I have a custom HTML tag: <custom>text is here</custom> I can do anything I would like in terms of calling methods with mozilla but not IE 6. For instance calling appendChild in IE results in an...
12
by: Noel | last post by:
Hello, I'm currently developing a web service that retrieves data from an employee table. I would like to send and retrieve a custom employee class to/from the webservice. I have currently coded...
8
by: Techno_Dex | last post by:
Has anyone come up with a slick way to make Custom Serializable Objects to behave like DataSets when using WebServices? What I'm looking for is some way to force the WSDL generated code to create...
9
by: Greger | last post by:
Hi, I am building an architecture that passes my custom objects to and from webservices. (Our internal architecture requires me to use webservices to any suggestion to use other remoting...
2
by: holisticnetworking | last post by:
I'm using the xmlHttpRequest object to gather images and place them on a page. Later in the script, I need to add a function to their onClick property so they can do the business I need them for. ...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.