Popup Window Example by Dario Medele

Contributed by
Rating: 5 stars5 stars5 stars5 stars5 stars / 12
May 18, 2001
Rate this Article:
MEH MEH++


SEARCH ASP FREE
TOOLS YOU CAN USE

advertisement

Pop up window

This example illustrates how to narrow down a search. The code below shows how to pop up a window that will get records and typing into the textbox will narrow down the selection. The actual demo will also pass a parameter to the pop-up window and has the option to keep the window open in case the form is accessed often. Simply view the code source for a complete reference of all the functionality.

To view the demos please follow this link. http://www.houndware.com/dario/pop.asp

Click on the search icon to open up a new window and type the parameter into the textbox.

 

This function opens a pop-up window
<%
'opening a recordset and dumping it into an array
'I assume you already know how to establish a connection

rs.Open strsql, strconn,adOpenStatic, adLockReadOnly, adCmdText
arData = rsWO.GetRows()
numCols= ubound(arData , 1 )
numRows= ubound( arData , 2)
%>

Also create a textbox and call it LastName. You can alternatively
pass the name of the textbox as a parameter to the javascript
function PopWin() as an option and your code will be more reusable

This is the ASP page

<%
'opening a recordset and dumping it into an array
'I assume you already know how to establish a connection

rs.Open strsql, strconn,adOpenStatic, adLockReadOnly, adCmdText
arData = rsWO.GetRows()
numCols= ubound(arData , 1 )
numRows= ubound( arData , 2)
%>
.......................................
<%Script language=javascript %>
// building the array
var arData = new Array();
var numRows = '<%=numRows + 1 %>';
var numCols = '<%=numCols%>';
<%
for I=0 to numRows
response.write ( "arData[" & I & "] = new Array();" & vbcrlf )
for J=0 to numCols
response.write ( "arData[" & I & "][" & J & "]= """ & arData(J,I) & """;" & vbcrlf )
next
next
end if %>
function sendBack(vValue)
{
window.opener.LastName.value = vValue;
}
function fillData()
{
var a= "";
var b="";
var varData = "" ;
var intLength = document.all.test.value.length ;
varData = "< table width=100% cellspacing=0 > < tr > < td > < font color=white > Last Name < /td > < td > < font color=white > First Name < /font> < /td > < /tr >";
for (var r=0 ; r < numRows ; r++ )
{
for (var c=0 ; c < numCols ; c++)
{
a= arData[r][0].substr(0,intLength);
b= document.all.test.value;
if ( a.toLowerCase() == b.toLowerCase() )
{
varData = varData + " < TR bgcolor=silver > < TD >< a href=javascript:sendback( " " + arData[r][0] + "')> " + arData[r][0] + "< /a > </TD > < td > " + arData[r][1] + " </td > </TR > " ;
}
} }
varData= varData + " </table> "
DataTran.innerHTML = varData ; // varData contains all the new data is set using innerHTML
}

And the last step is to add a div tag in you code.
Just like this:
< div id="Detail">
< p ID="DataTran"> </p>
< /div>



And that should do it. Again view the source of this page to see more functionality added to the script I hope this helps or give you new ideas on how to - or not to :) - search for specific records.
Dario Medele

 

blog comments powered by Disqus
ASP CODE ARTICLES

- ASP Forms
- ASP: The Beginning
- Getting Remote Files With ASP Continued
- Inbox and Outbox Manipulation in ASP
- Relational DropDownList Using VB.NET
- Ad Tracking URL Hits
- Use ViewState to display one record per page...
- Send Email using ASP.NET formatted in HTML
- ASP File Explorer
- ASP/XML Interview questions by Srivatsan Sri...
- Pressing RETURN won't submit the form
- This shows how you get the TEXT of a combo r...
- Group Data by Adrian Forbes
- Multiple checkbox select sample
- Multiple checkbox select with all values sam...

ASP Web Hosting ASP.Net Web Hosting Windows Web Hosting
 
 
 

ASP Free Forums 
 RSS  Tutorials RSS
 RSS  Forums RSS
 RSS  All Feeds
Site Map 
Request Media Kit
Write For Us Get Paid 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Privacy Policy 
Support 


© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 5 - Follow our Sitemap
Most Popular Topics
All ASP.Net Tutorials