Book Section
-----
TY JavaScript 3rd Ed.
Teach Yourself JS 1.5
Teach Yourself DHTML
Teach Yourself JS 1.3
LLWW: JavaScript

General Section
-----
Discussion Forum
Articles / Tips
JavaScript Links
About the Author
Privacy Policy
Contact Me



Other Sites
-----
Website Workshop
JavaScript Weblog

JavaScript Workshop Forums

 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
Changing the onclick of an Image in another window

 
Post new topic   Reply to topic    JSWorkshop Forum Index -> JavaScript
View previous topic :: View next topic  
Author Message
jimw13uk
New member
New member


Joined: 24 Oct 2002
Posts: 3
Location: West Midlands - England

PostPosted: Wed Feb 26, 2003 7:43 am    Post subject: Changing the onclick of an Image in another window Reply with quote

This is my code - it is on the unload event of a popupwindow - I am changing the image in the othwer window (works fine) and then I want the onclick action to be updated to have flip the 1/0 to indicate whther its in add or delete mode.



Code:

            var texttouse = window.parent.opener.parent.text.Form1.IMG1.action ;

            var findchar = "<%=XXXWeb.Web.UI.Constants.UM_MY_LIST_POPUP_TRANSACTION%>"; // character to remove from string

var dec = texttouse.indexOf(findchar);
var url1 = texttouse.substring(0,dec)

var url2 = texttouse.substr(dec+<%=XXXWeb.Web.UI.Constants.UM_MY_LIST_POPUP_TRANSACTION.length%>+1,1);

var url3 = texttouse.substr(dec+<%=XXXWeb.Web.UI.Constants.UM_MY_LIST_POPUP_TRANSACTION.length%>+2,texttouse.length);
if (url2 == 0){
   url2=1;
} else if (url2 == 1) {
   url2=0;
}
            
      Window.parent.opener.parent.text.Form1.IMG1.onclick=url1 + url2 + url3;


Any help on this would be great as I have tried all sorts fo things and it doesnt work
Back to top
View user's profile Send private message
phil karras
Senior Member
Senior Member


Joined: 15 Jul 2002
Posts: 1776
Location: MD

PostPosted: Wed Feb 26, 2003 8:57 am    Post subject: Reply with quote

You have your assignment name a bit mixed up:
Code:

Window.parent.opener.parent.text.Form1.IMG1.onclick=url1 + url2 + url3;


// should be???
window.opener.parent.text.Form1.IMG1.onclick=url1 + url2 + url3;


This means, window.opener is the window that opened this pop-up, then parent is the base frame of window.opener (if you're not using frames you don't need it) then I don't know what text is but Form1 is the form name, and IMG1 is a field in the form, and I guess you're trying to set it's onClick to some value. I don't believe that can be done.

I'd set a flag, a global var value, and then when you do an onClick you can check that flag's value to see what you want to do on that click.

Some explanation of each part of the above assignment would help.
_________________
Phil K
Circle Software Consulting
Test website: http://cs.yrex.com/
Guidelines for Posting: http://www.jsworkshop.com/posting.html
IHBAAA = It Has Been Asked And Answered
KISS: http://www.jsworkshop.com/bb/viewtopic.php?t=508


Last edited by phil karras on Wed Feb 26, 2003 9:20 am; edited 2 times in total
Back to top
View user's profile Send private message Visit poster's website
jimw13uk
New member
New member


Joined: 24 Oct 2002
Posts: 3
Location: West Midlands - England

PostPosted: Wed Feb 26, 2003 9:07 am    Post subject: Reply with quote

text is the name fo the frame
Form1 is the Form as you rightly summised.

The site is in .Net and is built using code behind pages etc... the onclick value is built from a database when the page initially loads and I just need to flick a flag in the URL depending each time it gets clicked.

Is the onclick event not updateable then ?
Back to top
View user's profile Send private message
phil karras
Senior Member
Senior Member


Joined: 15 Jul 2002
Posts: 1776
Location: MD

PostPosted: Wed Feb 26, 2003 9:19 am    Post subject: Reply with quote

Hey, just give it a try and see, then let us know. I'm just not sure but if the server-side code sets it and it works then perhaps you can change it. Otherwise do the same thing with a flag.

The problem may simply be your incorrect assignment. Let me try again as to what we have now that you've filled in the missing piece (which I should have been able to figure out, Dah!)

window.opener: is the window that opened this pop-up,
parent.text: is the frame which contains the form
Form1: is the form name, and
IMG1: is a field in the form,
onClick: is an event NOT a value
onclick: is I don't know, nothing?
_________________
Phil K
Circle Software Consulting
Test website: http://cs.yrex.com/
Guidelines for Posting: http://www.jsworkshop.com/posting.html
IHBAAA = It Has Been Asked And Answered
KISS: http://www.jsworkshop.com/bb/viewtopic.php?t=508
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    JSWorkshop Forum Index -> JavaScript All times are GMT - 7 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2002 phpBB Group
(c) 1997-2002 Starling Technologies and Michael Moncur. Portions (c) Sams Publishing.