469,327 Members | 1,219 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,327 developers. It's quick & easy.

Referencing an image via ID on main page from second form

RWC
Hello,

I have a page connected to an SQL table. The page loops through, creating a
row for each record, displaying in image, the ID of which is set to the
record id. When I click a button to change the image, I'd like to refer to
the ID on the main page, but change the image on the main page. Any idea
how to do this?

Example is as follows

Record 1 ID=1 NAME=Image1 Src=bird.jpg
Record 2 ID=2 NAME=Image1 Src=horse.jpg
Record 3 ID=3 NAME=Image1 Src=cow.jpg
When I open the child window and select a new image for Record 3, I'd like
to change the record 3 src to insect.jpg.

I've changed the value of things based on teh Name element but never the ID.
How do I do that?

Any help would be great!

Thanks in advance!
Rick
Jul 23 '05 #1
2 1268
RWC wrote:
Hello,

I have a page connected to an SQL table. The page loops through, creating a row for each record, displaying in image, the ID of which is set to the record id. When I click a button to change the image, I'd like to refer to the ID on the main page, but change the image on the main page. Any idea how to do this?

Example is as follows

Record 1 ID=1 NAME=Image1 Src=bird.jpg
Record 2 ID=2 NAME=Image1 Src=horse.jpg
Record 3 ID=3 NAME=Image1 Src=cow.jpg
These are not valid id's. An id:

"...must begin with a letter ([A-Za-z]) and may be followed by any
number of letters, digits ([0-9]), hyphens ("-"), underscores ("_"),
colons (":"), and periods (".")"

Though they probably work in most browsers (but that doesn't make them
valid HTML).

Using identical names for the images will cause problems also, though
most browsers will tolerate it. Names on images should be unique.
Browsers will likely return the first image with the name, but you
should not depend on that behaviour.

Your HTML should look something like like:

<tr><td><img name="Image1" id="Image1" src="brid.jpg"></td></tr>
<tr><td><img name="Image2" id="Image2" src="horse.jpg"></td></tr>
<tr><td><img name="Image3" id="Image3" src="cow.jpg"></td></tr>

Others may comment on the use of tables for layout...
When I open the child window and select a new image for Record 3, I'd like to change the record 3 src to insect.jpg.

I've changed the value of things based on teh Name element but never the ID. How do I do that?


The easiest way is to use the images collection:

opener.document.images['Image3'].src = 'insect.jpg'

--
Rob

Jul 23 '05 #2
RWC
Excellent. Thanks Rob, I will give that a try.

Rick

"RobG" <rg***@iinet.net.au> wrote in message
news:11*********************@o13g2000cwo.googlegro ups.com...
RWC wrote:
Hello,

I have a page connected to an SQL table. The page loops through,

creating a
row for each record, displaying in image, the ID of which is set to

the
record id. When I click a button to change the image, I'd like to

refer to
the ID on the main page, but change the image on the main page. Any

idea
how to do this?

Example is as follows

Record 1 ID=1 NAME=Image1 Src=bird.jpg
Record 2 ID=2 NAME=Image1 Src=horse.jpg
Record 3 ID=3 NAME=Image1 Src=cow.jpg


These are not valid id's. An id:

"...must begin with a letter ([A-Za-z]) and may be followed by any
number of letters, digits ([0-9]), hyphens ("-"), underscores ("_"),
colons (":"), and periods (".")"

Though they probably work in most browsers (but that doesn't make them
valid HTML).

Using identical names for the images will cause problems also, though
most browsers will tolerate it. Names on images should be unique.
Browsers will likely return the first image with the name, but you
should not depend on that behaviour.

Your HTML should look something like like:

<tr><td><img name="Image1" id="Image1" src="brid.jpg"></td></tr>
<tr><td><img name="Image2" id="Image2" src="horse.jpg"></td></tr>
<tr><td><img name="Image3" id="Image3" src="cow.jpg"></td></tr>

Others may comment on the use of tables for layout...
When I open the child window and select a new image for Record 3, I'd

like
to change the record 3 src to insect.jpg.

I've changed the value of things based on teh Name element but never

the ID.
How do I do that?


The easiest way is to use the images collection:

opener.document.images['Image3'].src = 'insect.jpg'

--
Rob

Jul 23 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by cjaserver | last post: by
8 posts views Thread by Cardman | last post: by
2 posts views Thread by Tom | last post: by
3 posts views Thread by jackiepatti | last post: by
reply views Thread by listenups61195 | last post: by
reply views Thread by Purva khokhar | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.