/    Sign up×
Community /Pin to ProfileBookmark

How to access a certain row

I have a table that is populated by a SQL query and on each row is an icon of an envelope. The icon is a link to a Javascript popup window so the user can send an email message to the person on that row of the table. The icon needs to change images when the email message is sent, and I was able to do that as long as the person being sent the email is on the top row of the table. If the recipient is lower than the top row, the image on the top row changes.

What I need to know is how can I access the image on a selected row to change the image.

Here is the code I have now:
{
parent.window.opener.document.getElementById(’emailIcon’).src =”images/emailIcon.jpg”
}

Any help someone could offer would be greatly appreciated.

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@vwphillipsJan 17.2008 — [CODE]<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">

<html>

<head>
<title></title>
<script language="JavaScript" type="text/javascript">
<!--
var SendImg;
function Open(img){
// open the popup
SendImg=img;
}

function Sent(){
SendImg.src='http://www.vicsjavascripts.org.uk/StdImages/Two.gif';
}
//-->
</script></head>

<body>
<table border="1">
<tr>
<td>Send Email<img src="http://www.vicsjavascripts.org.uk/StdImages/One.gif" width="30" height="30" onclick="Open(this);"></td>
</tr>
<tr>
<td>Send Email<img src="http://www.vicsjavascripts.org.uk/StdImages/One.gif" width="30" height="30" onclick="Open(this);"></td>
</tr>
</table>
<input type="button" name="" value="Simulate: parent.window.opener.document.Sent();" onclick="Sent();"></body>

</html>[/CODE]
Copy linkTweet thisAlerts:
@loydcampbellauthorJan 17.2008 — Vic, thanks. I think I can work through your example. It will have to be different since the sent button is in a different window, but I should be able to make it work with you example.

Thanks so much for your time and interest.
Copy linkTweet thisAlerts:
@vwphillipsJan 18.2008 — Note the code displayed as the button value
Copy linkTweet thisAlerts:
@loydcampbellauthorJan 30.2008 — I really appreciated Vic's help on this earlier. I think I have most of it right but for some reason it's not quite right. I changed the names of the functions, etc. so they would match up with what I was doing. here is my code in the initial template:

JAVASCRIPT AT TOP OF PAGE:

var NewEmailImg;

function ChangeImage(img){

alert("from functions.asp, ChangeImage function start");

NewEmailImg=img;

alert("from functions.asp, NewEmailImg = " + NewEmailImg);

}

function Change(){

alert("from functions.asp, Change function start");

emailIcon.src='http://www.txmobile.com/newWeb/admin/images/emailIcon.jpg';

alert("from functions.asp, Change function end");

}

<a href="#"

onClick="alert('from setEmailIcon.asp, onClick event start');

ChangeImage(this); openPopWin('emailResponseUpgrade.asp?ID=<%=rs("cid")%>&uID=<%=rs("urpID")%>&pID=<%=pID%>&pg=<%=pqs%>', 575, 465, 'scrollbars', 20, 20); alert('from setEmailIcon.asp, onClick event end');">

<% If rs("eCount") <> 0 then %>

<img id="emailIcon" name="emailicon" border="0" src="images/emailIcon.jpg" width="26" height="30">

<% Else %>

<img id="emailIcon" name="emailicon" border="0" src="images/emailIcon2.jpg" width="32" height="30">

<% End if %>

</a>

IMAGE AND LINK CODE (rs(eCount) comes from a db query):

<a href="#"

onClick="alert('from setEmailIcon.asp, onClick event start'); ChangeImage(this); openPopWin('emailResponseUpgrade.asp?ID=<%=rs("cid")%>&uID=<%=rs("urpID")%>&pID=<%=pID%>&pg=<%=pqs%>', 575, 465, 'scrollbars', 20, 20); alert('from setEmailIcon.asp, onClick event end');">

<% If rs("eCount") <> 0 then %>

<img id="emailIcon" name="emailicon" border="0" src="images/emailIcon.jpg" width="26" height="30">

<% Else %>

<img id="emailIcon" name="emailicon" border="0" src="images/emailIcon2.jpg" width="32" height="30">

<% End if %>

</a>

JAVASCRIPT IN POPUP WINDOW:

function changeEmailIcon()

{

alert("from eTxtBox.asp, changeEmailIcon function start");

parent.window.opener.document.Change();

alert("from eTxtBox.asp, changeEmailIcon function end");

}

CALLING CODE IN POPUP WINDOW:

<input type="button" value="Send Email Message" onClick="alert('from eTxtBox.asp, submit button click'); changeEmailIcon();">


I left all the alerts in and they popup on schedule until it gets to the action line, parent.window.opener.document.Change(). the alert just before that line works, but the action line doesn't make the image change and the alert right after that doesn't show. There isn't an error thrown, and I've tried several other calls, like window.opener.Change(), parent.parent.window.opener.document.change(), but nothing seems to work. Can anyone tell what I'm missing?

Thanks again for any help on this.
×

Success!

Help @loydcampbell spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...