Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to capture a pop-up window's SELECTed VALUE? 1

Status
Not open for further replies.

zombee

Programmer
May 16, 2008
18
US
My HTML markup contains a div with an id of "buttons".
Within the div is a button defined as:
<input type='button' id='seeHistory' value='See History'>

This button's event handler that looks like this:

case "See History":
document.getElementById("buttons").style.display = 'none';
//Remove buttons from display
makeNewWindow();
writeToWindow();

// Here is where I need to capture & process the select value made in this window

document.getElementById("buttons").style.display = 'block';
//Redisplay buttons
break;


The functions are here defined:

function makeNewWindow() {

// make sure it isn't already opened

if (!g_newWindow || g_newWindow.closed) {
g_newWindow = window.open("","seeHx","height=260,width=350,toolbar=0,menubar=0,scrollbars=0,resizable=0,location=0,directories=0,status=0");
setTimeout("writeToWindow()", 50); // delay writing until window exists in IE/Windows
}
// window is already open or focusable, so bring it to the front
g_newWindow.focus();
}

function writeToWindow() {
var newContent = "<html><head><title>History of Calls</title></head>";
newContent += "<body><em><h3>Select person called</h3></em><br />";
newContent += "<SELECT name='selectID'>";
for (x=0; x < g_array.length; x++) {
newContent += "<option value = '"+g_array[x][0]+"'>&nbsp;"+g_array[x][1]+"&nbsp;&nbsp;"+g_array[x][2]+"&nbsp;</option>";
}
newContent += "</SELECT><br /><br />";
newContent += "<INPUT TYPE='cancel' VALUE='Quit' onClick='self.close()' />";
newContent += "&nbsp;&nbsp;&nbsp;<INPUT TYPE='submit' VALUE='Submit' onClick='self.close()' />";

// HOW DO I GRAB THIS VALUE ON CLOSE of the SUBMIT ??

newContent += "</body></html>";

// write HTML to new window document

g_newWindow.document.write(newContent);
g_newWindow.document.close( );
// close layout stream
}


 
As I explained in your previous post, using a standard popup window, you cannot "wait" for the window to close before continuing execution of your JavaScript.

You need to re-work your code so that you don't need to wait, instead relying on some other trigger. Whether this is your own custom "close" button in the popup, or whether you auto-close "onchange", or even something else... whatever is right for your users, really.

Hope this helps,
Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
How would you tackle this circumstance?

Suppose a person, who checks his caller-id,
dials me back sometime after I called him.
Then he asks me to remove him from my list.
I now need to retrieve this person's id
from a list of already-called people,
to go ahead and delete this guy's records.

How can I restructure my code or strategy to achieve this?
 
I must have missed something in both your posts, because I thought you were asking how to run some JavaScript only after a window was closed.

I now see you want help to delete something from a list (or a database?), so perhaps you're asking in the wrong forum?

Maybe the best thing to do is to sit down, work out what you actually want, and put it in a structured, concise post that is easily understandable.

Hope this helps,
Dan





Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Dan - you're misunderstanding me.

I'll deal with the database issue later, using ajax
as I use it elsewhere in my code.

For now, I need to know how to capture the SELECT value
from the HTML picklist that pops up in the javascripted child window. (See code in thread's opener).

That's my whole problem.
This is a javascript issue - not a database issue!
 
You could attach an onchange to the select element to call a function in the main page with its value... something like this:

Code:
<select name="whatever" onchange="window.opener.selectValueChanged(this.value);">

and as long as you have a function called "selectValueChanged" in your main window, you should be set.

Hope this helps,
Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top