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! | Build secure Web services with transport-level security using IBM Rational Application Developer V7 and IBM WebSphere Application Server V6.1. Follow this three-part series for step-by-step instructions about how to develop Web services and clients, configure HTTP basic authentication, and configure HTTP over SSL (HTTPS). This first part of the series walks you through building a Web service for a simple calculator application. You generate and test two different types of Web services clients: a Java Platform, Enterprise Edition (Java EE) client and a stand-alone Java client. You also handle user-defined exceptions in Web services. FREE! Go There Now!
| | | | Join us for this on demand webcast to learn about developing complex systems more quickly and efficiently. We'll cover market drivers for developing, governing and reusing systems software assets and how you can develop system software assets with Rational Asset Manager. FREE! Go There Now!
| | | | Download the Rational Application Developer (RAD) v7.5 open beta code and start developing applications for the JEE5 standard which features EJB3.0, JPA, JSF 1.2, JSP 2.1 and Servlet 2.5 standards. When you use this beta you will see how you can increase developer productivity for already existing applications with improved support for refactoring, as well as adding new features to existing applications. In addition, the beta provides tooling for JD Edwards, Oracle, SAP, Siebel and PeopleSoft to improve the developer productivity with these enterprise systems. FREE! Go There Now!
| | | | Listen to this webcast to get an overview of Info 2.0 and a technical demo of how to quickly build an enterprise mashup. IBM's Info 2.0 technology leverages emerging Web 2.0 technologies such as mashups, feeds, AJAX, and JSON in order to simplify assembly of information using feeds and services. Come learn about the technical elements of Info 2.0 including the Feed Generation framework, Mashup Engine, and mashup assembly components. Learn how to pull information from databases, departmental information, and the Web to create mashups critical to your company’s success. We will also discuss best practices to help you get started. FREE! Go There Now!
| | | | XML has become a common way of storing business data as flat files and many data server vendors including IBM have provided ways to store this data within relational database systems. Increasingly collections of XML files are accessed like databases using an xQuery and other XML standard mechanisms. Businesses find the need to combine the traditional tabular structured data with XML formatted data. In this webcast, you’ll learn about IBM’s WebSphere Federation Server technology, which provides users with the ability to integrate these two data formats. FREE! Go There Now!
| | | | This Fall, IBM Rational talks to you directly through a special teleconference series giving you access to the best minds in IBM Rational - product experts and market thought leaders who will answer your questions during these pre-scheduled telephone conference calls. Register today! FREE! Go There Now!
| | | | Visit IBM developerWorks to try the IBM SOA Sandbox for connectivity. The SOA Sandbox for connectivity provides a trial environment with the tooling and components to help you explore how to effectively connect your infrastructure and integrate all of the people, processes and information in your company. Use the hosted sandbox to explore SOA techniques that streamline connecting existing IT assets together, as well as learn how to connect them to new business logic. FREE! Go There Now!
| | | | As businesses grow increasingly dependent upon Web applications, these complex entities grow more difficult to secure. Most companies equip their Web sites with firewalls, Secure Sockets Layer (SSL), and network and host security, but the majority of attacks are on applications themselves – and these technologies cannot prevent them. This paper explains what you can do to help protect your organization, and it discusses an approach for improving your organization’s Web application security. FREE! Go There Now!
| | | | Attend this launch webcast with Scott Hebner, Vice President of IBM Rational Marketing and Strategy, where he will overview Rational’s new offerings and programs to help customers accelerate software innovation on System z. He will discuss how these solutions help organizations extend their core business processes toward modern architectures such as SOA and web technologies to deliver business improvements that stand the test of time. FREE! Go There Now!
| | | | The unprecedented scope of a service-oriented architecture (SOA) initiative brings to the forefront a number of management and governance issues that were sidestepped in the past. The key to a successful SOA implementation is managing and governing activities throughout the entire SOA delivery lifecycle by ensuring that services conform to the needs of all of the business’s stakeholders. Learn how service lifecycle management allows the business to ensure that the process by which services are defined, created, tested, deployed, optimized and retired is manageable, repeatable and auditable. FREE! Go There Now!
| | | | All FREE IBM® developerWorks Tools! | |