How could the server possibly know what a client is doing?
When you open the popup you ust need to pass the required values, as Greg suggested, via the POST or GET method. You then read these server-side and build your SQL (or use a stored procedure which is far safer).
A simple example, on the main page:
Code:
function openPopup()
{
//Get the surname from the textbox
var sSurname = document.getElementById("txtSurname").value;
//Encode surname in case of non ASCII characters
sSurname = encodeURIComponent(sSurname);
//Build the URL to the popup
var sUrl = "myPopupPage.htm?Surname=" + sSurname;
var oWin = window.open(sUrl);
}
Then server-side, assuming ASP and SQL Server or such:
Code:
<%
var sSurname = Request.Querystring.item("Surname") + "";
//In real life use Adodb.command etc with stored proc
//to avoid SQL injection and single quote problems etc.
var sSql = "Select * FROM tblCustomer WHERE Surname = '"
+ sSurname + "'"
//Execute SQL and show results
%>
--
Joe (
Microsoft MVP - XML)