| View previous topic :: View next topic |
| Author |
Message |
jimw13uk New member

Joined: 24 Oct 2002 Posts: 3 Location: West Midlands - England
|
Posted: Wed Feb 26, 2003 7:43 am Post subject: Changing the onclick of an Image in another window |
|
|
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 |
|
 |
phil karras Senior Member

Joined: 15 Jul 2002 Posts: 1776 Location: MD
|
Posted: Wed Feb 26, 2003 8:57 am Post subject: |
|
|
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 |
|
 |
jimw13uk New member

Joined: 24 Oct 2002 Posts: 3 Location: West Midlands - England
|
Posted: Wed Feb 26, 2003 9:07 am Post subject: |
|
|
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 |
|
 |
phil karras Senior Member

Joined: 15 Jul 2002 Posts: 1776 Location: MD
|
Posted: Wed Feb 26, 2003 9:19 am Post subject: |
|
|
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 |
|
 |
|