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 |
|
| DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware. |
More ASP Code Articles More By aspfree developerWorks - FREE Tools! | Learn to enable users to both rate existing animations and to combine existing animations into new snippets. This is the third in a series of three tutorials that chronicle the building of a site that enables collaborative discussion and animation building using Domino and OpenLaszlo. FREE! Go There Now!
| | | | Learn how you can extend modern application lifecycle management to IBM System z through the IBM Rational Software Delivery Platform (SDP). The Did you say mainframe? e-kit includes podcasts, webcasts, tutorials, white and red papers, demos, and articles designed to help ease the challenges of modernizing your enterprise. This complimentary kit for mainframe developers is a practical, how-to guide for making the most of an existing development environment, including the skills and infrastructure already in place at an established enterprise. FREE! Go There Now!
| | | | Visit IBM developerWorks to download a free trial of the latest release of IBM Lotus Sametime Standard V8.0. Lotus Sametime Standard V8.0 is a platform for unified communications and collaboration that combines security features with an extensible, open solution including integrated Voice over IP, geographic location awareness, mobile clients, and a robust Business Partner community offering telephony and video integration. FREE! Go There Now!
| | | | Visit IBM developerWorks to download a free trial version of IBM Rational Business Developer V7.1. Rational Business Developer offers rapid and simplified development of business applications and services through Enterprise Generation Language (EGL) tools, generating Java or mainframe solutions while shielding developers from technical complexities. FREE! Go There Now!
| | | | IBM Enterprise Modernization solutions help organizations evolve core IT systems towards modern architectures and technologies—reducing the burden of maintenance and freeing up resources to develop new business requirements and capabilities. With the IBM Enterprise Modernization Sandbox for System z you can evaluate IBM Enterprise Modernization solutions focused on five key areas: Assets, Architectures, Skills, Processes and Infrastructures, and Investment. Each solution is based upon real customer experiences and offers a proven path to get you started with your modernization projects. FREE! Go There Now!
| | | | As organizations have grown increasingly dependent on online software, the risk of malicious attacks has also become far more serious. Fortunately, well-governed organizations can protect their Web applications by injecting vulnerability assessments and ethical hacks into their software development and delivery processes. This paper describes 12 of the most common hacker attacks and provides basic rules that you can follow to help create more hack-resistant Web applications. FREE! Go There Now!
| | | | Get a free trial download of the latest version of IBM Rational Method Composer V7.2 which helps you deliver customized yet consistent process guidance to your project teams and IT organization, and includes the latest version of IBM Rational Unified Process (RUP), which has provided process guidance to teams since 1996. FREE! Go There Now!
| | | | Get a free trial download of the latest version of IBM Rational Performance Tester V7.0.1, a load and performance testing solution for teams concerned about the scalability of their Web-based applications. Combining multiple ease-of-use features with granular detail, Rational Performance Tester simplifies the test-creation, load-generation and data-collection processes that help teams ensure the ability of their applications to accommodate required user loads. FREE! Go There Now!
| | | | Visit IBM developerWorks to try the IBM SOA Sandbox for people. The SOA Sandbox for people provides a trial environment with the necessary tooling and components required to enable consistent human and process interaction and collaboration, showing how you can improve user experience and business productivity. FREE! Go There Now!
| | | | In this webcast, you'll get an introduction to the eXtreme Transaction Processing (XTP) features of WebSphere Extended Deployment and the common architectural traits required by XTP applications. See how WebSphere Extended Deployment's ObjectGrid feature provides a state-of-the-art infrastructure for hosting XTP applications. FREE! Go There Now!
| | | | All FREE IBM® developerWorks Tools! | |