ShadowMage Posted September 8, 2009 Share Posted September 8, 2009 I am trying to make a link that displays information when you hover over it, and when it's clicked you can edit the information. In the onmouseover event, I call a function to open a new window, and on the onmouseout event it closes the window. Both of these work perfectly. The problem comes in when I try to click and edit the information. The pop up is loaded from the same php file, and the same JavaScript method. The only difference is that a variable is passed to indicate clicked or hovered. If clicked, the window should be loaded to allow editing. If hovered, it should be loaded as readonly.This is how I currently have it. When clicked this just loads the window in readonly mode, as if I had hovered over it. <input type='text' name='myInput' value='-' onmouseover='showWindow(0);' onmouseout='hideWindow();' onclick='showWindow(1);'/> I have also tried this: <a target='_blank' href='myWindow.php?Clicked=1' onmouseover='showWindow(0);' onmouseout='hideWindow();'>Edit</a> But this, when clicked loads a completely different window. I've tried changing the target to '_self' and 'new' but neither one works like I want. '_self' opens the editable page in the parent window instead of the pop up.I hope I've made this clear enough as to what I'm trying to do. Any advice is much appreciated, thank you.jkloth Link to comment Share on other sites More sharing options...
Ingolme Posted September 8, 2009 Share Posted September 8, 2009 It would help to know what the showWindow() function looked like. Link to comment Share on other sites More sharing options...
ShadowMage Posted September 8, 2009 Author Share Posted September 8, 2009 Sorry about that, here are the functions I'm using: <script type='text/javascript'>var newWindow = null;var locked = 0;var x = 0;function showWindow(blnClicked) { if (locked == 0) { x++; if (x == 1) { newWindow = window.open("Forms/myWindow.php?Clicked="+blnClicked, "newWindow ", "toolbar=no, location=no, directories=no, titlebar=no, status=no, menubar=no, scrollbars=no, resizable=no, width=550, height=400"); } } if (blnClicked != 0) { locked = 1; //if clicked change to 1, if not clicked don't change value, value will be reset when newWindow is closed newWindow .focus(); }}function hideWindow() { if (locked == 0) { newWindow .close(); newWindow = null; x = 0; }} Link to comment Share on other sites More sharing options...
Ingolme Posted September 8, 2009 Share Posted September 8, 2009 Sorry about that, here are the functions I'm using: <script type='text/javascript'>var newWindow = null;var locked = 0;var x = 0;function showWindow(blnClicked) { if (locked == 0) { x++; if (x == 1) { newWindow = window.open("Forms/myWindow.php?Clicked="+blnClicked, "newWindow ", "toolbar=no, location=no, directories=no, titlebar=no, status=no, menubar=no, scrollbars=no, resizable=no, width=550, height=400"); } } if (blnClicked != 0) { locked = 1; //if clicked change to 1, if not clicked don't change value, value will be reset when newWindow is closed newWindow .focus(); }}function hideWindow() { if (locked == 0) { newWindow .close(); newWindow = null; x = 0; }} The reason your first approach didn't work is because you're destroying the reference to the window with this line:newWindow = null;Remove that line and the following should work:<input type='text' name='myInput' value='-' onmouseover='showWindow(0);' onmouseout='hideWindow();' onclick='showWindow(1);'/> Link to comment Share on other sites More sharing options...
ShadowMage Posted September 9, 2009 Author Share Posted September 9, 2009 The reason your first approach didn't work is because you're destroying the reference to the window with this line:newWindow = null;Remove that line and the following should work:<input type='text' name='myInput' value='-' onmouseover='showWindow(0);' onmouseout='hideWindow();' onclick='showWindow(1);'/> I removed that line and it's still not working. For some reason it's always firing the showWindow() method with blnClicked = 0. I even tried changing the default value for Clicked in my php file to '1' to see if there was an issue with the POST but it still loads with Clicked = 0. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.