Guest Phoenix_Riser Posted March 23, 2006 Share Posted March 23, 2006 Firstly please nit pick any part of this code!!The thing I want to do though is to select a user by clciking on one of the displayed lines and then have those details transefered to a textbox. Basically when a client calls up we want to search the database and find a current customer if they have been recommended.Thank you in advance. I confess I am totally stumpted on how to do this and even some pointers would be apperciated. <% Option Explicit %><!------------------------------------------------------------------------------------------------------------><!-- HTML Code --> <html> <head> <title>Database</title> </head> <body> <!-- Displays front end search box --><form name="form1" method="post" action=""><input name="search" type="text" value="" onKeyUp="this.form.submit();"><input name="show" type="Submit" value="Reset"></form><!-- //Displays front end search box --><!-- //HTML Code --><!-- Session hits - On initial open don't need to ask user to fill in box, only if they incorrectly search do we do that --><p> <%Session("hits") = Session("hits")+1If Request.Form("show") = "Reset" OR Request.Form("search") = "" Then search = "hidden" If Session("hits") <> 1 Then response.Write("Please search by filling in the box above") End Ifelse'Set Dims line 1, values for or from input, line 2 - connection,search facility and character checking variables Dim search, searchtext1, searchtext, value2, rs, IpAddress, name1 Dim Conn, sConnection, recordsonpage, requestrecords, hiddenrecords, showrecords, recordcounter, lastrecord, acceptableChars ''''''''''''''''' searchtext = Request.Form("search") searchtext = LTrim(searchtext) 'removes excess left spaces searchtext = UCASE(searchtext) 'make TEST Test and test Test, can be useful searchtext = replace(searchtext,"'","") acceptableChars="abcdefghijklmnopqrstuvwxyz"'If InStr(acceptableChars, searchtext) = 0 and Not IsNumeric(searchtext) ThenIf InStr(acceptableChars, searchtext) = 0 and Not IsNumeric(searchtext) Then response.Write("!!" & searchtext & "!!") ''''''''''''''''' Set Conn = Server.CreateObject("ADODB.Connection") sConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" & Server.MapPath("PC_detail.mdb") & ";" & "Persist Security Info=True" Conn.Open(sConnection) ' records per page, no paging in this case as not needed but alot tidier to just have up to 20 recordsonpage = 10 ' opens database set rs = conn.Execute("Select * From main Where Name1 Like '%" & searchtext & "%'") %> <p></p> <table cellspacing="2" cellpadding="2" border="1"> <% ' prints records in the table showrecords = recordsonpage recordcounter = requestrecords do until showrecords = 0 OR rs.EOF recordcounter = recordcounter + 1 %> </p> <tr> <td width="10"><% = recordcounter %></td> <td width="120"><% = rs("IpAddress") %></td> <td><% = rs("name1") %></td> </tr> <% showrecords = showrecords - 1 rs.movenext if rs.EOF then lastrecord = 1 else end if loop Else searchtext = "" response.Write("Invalid character") End IfEnd If%> <script> function insertAtCursor(myField, myValue) { //IE support if (document.selection) { myField.focus(); sel = document.selection.createRange(); sel.text = myValue; } //MOZILLA/NETSCAPE support else if (myField.selectionStart || myField.selectionStart == '0') { var startPos = myField.selectionStart; var endPos = myField.selectionEnd; myField.value = myField.value.substring(0, startPos) + myValue + myField.value.substring(endPos, myField.value.length); } else { myField.value += myValue; } } // calling the function insertAtCursor(document.form1.search, '<%=searchtext%>'); </script> Link to comment Share on other sites More sharing options...
vinphetamin Posted May 1, 2006 Share Posted May 1, 2006 <style> a{cursor:pointer;}</style><form id="myForm"> <input type="text" name="myField" /></form><a onclick="document.getElementById('myForm').myField.value='One';">One</a><br /><a onclick="document.getElementById('myForm').myField.value='Two';">Two</a><br /><a onclick="document.getElementById('myForm').myField.value='Three';">Three</a><br /> Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now