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 |
|