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. However, after having placed them on the page, I cannot then snatch them up again to add the onClick.
I'll readily accept the premise that I'm doing something backwards, but because a) the function I want to add to the onClick property is a method of the kioskDemo prototype and b) I want to pass the 'this' object to the method to make it work, it seems to me that I would want to add the onClick method later in the program, rather than when I'm building it in the getImages method.
Here's the relevant code: - kioskDemo.prototype.getImages = function() {
-
var source = '/global/mul/digital/kiosk/xml/'+this.page+'_'+this.country+'.xml';
-
HTTP.getXML(source, return_result);
-
function return_result(result) {
-
var items = result.getElementsByTagName('collection')[0];
-
for(x = 0; x<items.childNodes.length; x++) {
-
if(items.childNodes[x].tagName) {
-
var images = items.childNodes[x];
-
var nameTag = images.tagName.toString();
-
var target = document.getElementById(nameTag);
-
for(y = 0; y < images.childNodes.length; y++) {
-
if(images.childNodes[y].tagName) {
-
var hlink = document.createElement('A');
-
hlink.setAttribute('href','javascript: void(0);');
-
hlink.setAttribute('class', 'k_button');
-
// addEvent(hlink, 'click', kioskChangeFile);
-
var image = document.createElement('img');
-
image.src = images.childNodes[y].getAttribute('src');
-
image.id = images.childNodes[y].getAttribute('name');
-
target.appendChild(hlink);
-
hlink.appendChild(image);
-
}
-
}
-
}
-
}
-
}
-
}
-
-
-
-
function launchKiosk() {
-
k.getImages();
-
var demo_container = document.getElementById('demo_container');
-
// A bunch of other unrelated code. . .
-
var img_buttnz = document.getElementsByTagName('A');
-
alert(img_buttnz.length);
-
/* at this point, I found out that I cannot see these objects at all. */
-
}
2 2025 iam_clint 1,208
Recognized Expert Top Contributor -
target.appendChild(hlink);
-
hlink.appendChild(image);
-
You should really append image to hlink before you append hlink to target -
hlink.appendChild(image);
-
target.appendChild(hlink);
-
Also give your hlink a name and id in the loop.
Also give your hlink a name and id in the loop.
iam_clint, thanks very much for the quick reply, that helped!
Sign in to post your reply or Sign up for a free account.
Similar topics |
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 calculate the totals in each row.
when i try however, i receive the error:
"Error: 'elements' is null or not an object"
|
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 javascript
that adds a new line with HTML inputboxes and lists to the form if they
press a button.
|
by: Shawn Modersohn |
last post by:
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"
|
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 it
if anyone need such a function.
function append_children() {
var a = append_children.arguments;
|
by: Stewart |
last post by:
Originally posted in comp.lang.javascript:
Newsgroups: comp.lang.javascript
From: "Stewart"
Date: 23 Aug 2005 02:50:04 -0700
Local: Tues, Aug 23 2005 10:50 am
Subject: FireFox, RemoveChild, AppendChild, making width grow?
Hi,
| |
by: ezmiller |
last post by:
So I have some code that gets the body element of another frame and
then tries to
dynamically write a table. The code fails when, after creating the
table, I try to
append it to the document. I get an invalid argument error.
Here's the code....
var docBody =
top.frames.document.getElementsByTagName("BODY");
|
by: Jake Barnes |
last post by:
I'm trying to learn AJAX so tonight I sat down and came up with a
little toy that I can do tests with. You can see it here:
http://www.publicdomainsoftware.org/ajaxExperiment.htm
I've got Stuart Langridge's book "DHTML Utopia: Modern Web Design using
Javascript and DOM" which seems pretty good. It covers the basics.
The next thing I'd like to do is add a Save button to this little page
I came up with. I may use Sam Stephenson's...
|
by: Olorin |
last post by:
Hello everyone. I'm playing around with some AJAX-ish stuff and
encountered some problem in the JS side of the universe. Maybe someone
here can suggest an alternative that works.
I have developed a simple ASP.NET application with a web page that
should display a list of users. This list page is designed to start
with an empty table (with columns defined), and, onload, send an
XmlHttp request to a server component (a.k.a. ListServer)....
|
by: vsanjit |
last post by:
Hi all,
I've been trying to create a table dynamically upon the generation of en event using the appendChild method in Javascript. This seems to work fine in Firefox, but not in IE7. There's also no error message from IE. I'm new to these routines. Could someone shed some light on where I could be going wrong? Here's the code:
<html>
<head>
<script type='text/javascript'>
function makeTable()
{
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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 then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |