Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-12-2007, 05:36 PM   PM User | #1
tripwater
Regular Coder

 
Join Date: May 2005
Posts: 262
Thanks: 4
Thanked 0 Times in 0 Posts
tripwater is an unknown quantity at this point
Set imgage src in function

Hello, I am a php programmer and so I am not the best with JS. With that said, I have a page with an iframe.


The iframe holds thumbnails. When you click on a thumbnail, I would like for it to change the image on the parent page. So my issue is that I do not know how to set the img src inside my function. Here is what I have

Code:
function SetLargeImage(SRC)
{
var idsplit=SRC.split(/_/);
var imageid=idsplit[1];
//alert(imageid);
parent.document.getElementById('M_1').src='http://www.mysite.net/gallery/medium/M_\'+imageid+\'.jpg';

}
here is the call. This is the one of the thumbnails. In the parent page, the img tag that I am trying to set the source to has the id of M_1

Code:
<img id=\"T_".$row["ImageID"]."\" src=\"http://www.mysite.net/gallery/thumbs/T_".$row["ImageID"].".jpg\" onclick=\"SetLargeImage(this.id);\" >

Here is the img tag on my parent page
Code:
<img id="M_1" name="M1" border="0" />
THank you for any help with this

Last edited by tripwater; 01-12-2007 at 05:46 PM..
tripwater is offline   Reply With Quote
Old 01-12-2007, 06:05 PM   PM User | #2
brandonH
Regular Coder

 
Join Date: Oct 2003
Location: on a ship
Posts: 574
Thanks: 1
Thanked 6 Times in 5 Posts
brandonH is on a distinguished road
hey there trip....


the above code:

Code:
function SetLargeImage(SRC)
{
var idsplit=SRC.split(/_/);
var imageid=idsplit[1];
//alert(imageid);
parent.document.getElementById('M_1').src='http://www.mysite.net/gallery/medium/M_\'+imageid+\'.jpg';

}
should look like so:

Code:
function SetLargeImage(SRC)
{
var idsplit=SRC.split(/_/);
var imageid=idsplit[1];
//alert(imageid);
parent.document.getElementById('M_1').src='http://www.mysite.net/gallery/medium/M_'+imageid+'.jpg';

}
if you are trying escape the single quote becasu of php, try using double quotes instead.
__________________
I make no attempt at pretending like I'm a professional. I offer help with what knowledge I do have.
brandonH is offline   Reply With Quote
Old 01-12-2007, 06:14 PM   PM User | #3
tripwater
Regular Coder

 
Join Date: May 2005
Posts: 262
Thanks: 4
Thanked 0 Times in 0 Posts
tripwater is an unknown quantity at this point
Thanks brandonH, I knew it had to be something simple...
tripwater is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 02:17 PM.


Advertisement
Log in to turn off these ads.