473,803 Members | 3,833 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Help! Generating new <img> tags

# SIMPLE VERSION #
Is there a way I can create a new <img> tag onClick?
# DETAILED VERSON #
I'm making a game that involves drawing a path between two points on a
grid. I've got the pathfinding routine working fine, but drawing it
out on a grid is proving difficult. Since I can't just draw a line
segment, I made a set of graphics to use: a bit of horizontal line,
vertical line, and two diagonals. I just take a few copies of each and
move them around to where they need to be. However, the number of
these graphics (and, thus, the number of <img> tags) I'm going to need
is impossible to predict. How can I add (and, for extra credit,
remove) <img> tags to the page without having to reload?
# PSEUDO-CODE VERSION #
function NewImg(url){
document.addHTM L('<img src="' + url + '" alt="">');
}
..
..
..
<input type="button" value="Add" onClick="NewImg (url);">

Jul 23 '05 #1
2 1711
Th******@gmail. com wrote:
# SIMPLE VERSION #
Is there a way I can create a new <img> tag onClick?
# DETAILED VERSON #
I'm making a game that involves drawing a path between two points on a
grid. I've got the pathfinding routine working fine, but drawing it
out on a grid is proving difficult. Since I can't just draw a line
segment, I made a set of graphics to use: a bit of horizontal line,
vertical line, and two diagonals. I just take a few copies of each and
move them around to where they need to be. However, the number of
these graphics (and, thus, the number of <img> tags) I'm going to need
is impossible to predict. How can I add (and, for extra credit,
remove) <img> tags to the page without having to reload?
# PSEUDO-CODE VERSION #
function NewImg(url){
document.addHTM L('<img src="' + url + '" alt="">');
}


function NewImage(u){
var oImg = document.create Element('img');
oImg.src = u;
oImg.alt = '';
document.getEle mentsByTagName( 'body')[0].appendChild(oI mg);
}

[...]

--
Fred
Jul 23 '05 #2
That'll work, thanks!

Jul 23 '05 #3

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

Similar topics

3
6597
by: Ralph Freshour | last post by:
I have a PHP web app using MySQL - when I save a .jpg file named test's.jpg I see that the filename on the unix server is: test\'s.jpg - the filename I end up saving in my SQL table is named test's.jpg - when I use an image tag to display the photo on my web page, no image displays. I tried to strip the slash out of the filename but the image still won't display on the web page - maybe I'm all goofed up here and don't understand what's...
1
1469
by: A | last post by:
Hi everyone I was working on a php script to display images and I am running into problems. My problems are when I execute the query to thumb path it won't display the image/s. Anyhelp is alway's appreciated I have a mysql table with the following structure
5
1711
by: Lui Ali | last post by:
Hello, Problem: I want to get the whole text between the opening tag <%OPTIONAL%> and the closing tag <%/OPTIONAL%>. The right block is found by (and contains) the placeholder {#xmreisepop_reisepreistext_1_3#}. <%OPTIONAL%> and <%/OPTIONAL%> are not allowed to be inside these tags again.
8
5748
by: Hostile17 | last post by:
Consider the following HTML. ---------- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd"> <html> <head> <meta http-equiv=Content-Type content="text/html; charset=iso-8859-1"> <title>Untitled</title>
2
1720
by: Got2Go | last post by:
Hello, I am trying to come up with a function that will search the source of the page for a specific string. If that string is found, then have it modify specific tags inside of a table and display a link on the page. This link, when clicked will then restore the modified tags back to their original values.
4
1529
by: Paul Hale | last post by:
Hi, This is my set up... Root (.aspx file for non-authenticated users) Root\Members (.aspx files for authenticated users) Root\Images (images for entire web site) My MasterPage resides in Root.
2
1631
by: David Elliott | last post by:
I am creating a control to display GIF/JPEG images for my website. The control has a Panel to hold the images. I would like to perform the following. 1) store the original on disk and create a thumbnail on the fly. 2) thumbnail will be 20% of the original size. 3) the panel will hold all the images of a specific directory Using System.Drawing.Image, I can satisfy number 1 and 2, but how would I output the info to the panel?
2
1304
by: Sorbitol | last post by:
I'm trying to put two adjacent img tags inside a table cell example: <td><img class="imgclass" src=""/><img class="imgclass" src="" /></td> but i'm getting always a line break between images the following is the css code for imgclass:
1
10387
by: Dave | last post by:
Usual apologies if this is old territory. I'm resizing a bunch of iframes on a page to the height of their contained documents. Some of the contained documents contain IMG tags. On IE this doesn't cause a problem and the resize works correctly. On Firefox, if an image extends below the last line of text in the document, that bit gets chopped off. In other words, the returned document height doesn't allow for the image. My code for...
7
2900
by: ojsimon | last post by:
Hi I found this script on a forum and have been trying to make it work, but all it returns is a blank screen, i tried using the debug error reporting but got nothing from that either just a blank page, here is the code<?php //In this case, it fetches a search for "fresh content" from www.alltheweb.com, whom we hope you will visit. $theLocation="http://www.alltheweb.com/search?cat=web&q=fresh+content&phrase=on&h=50"; //Below, at $start and...
0
9699
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, 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...
0
10542
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10309
jinu1996
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...
1
10289
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,...
0
10068
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9119
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, 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...
1
7600
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 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...
0
5625
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3795
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.