Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How would I do this?

Status
Not open for further replies.

Lenvdb

Programmer
Jun 21, 2002
81
0
0
GB
Heya gurus and wizzards! Me gain beging for some help.
I work in VID and are attempting the following:

I have a Input textbox and next to it a <A HRef> tag.
Underneath I have a Listbox as in a <SELECT>

A user will type the first few letters of a customer surname, and with the A HREF tag which has a OnClick method, trigger a function that must get data from a database and convert it into an array , which must populate the listbox with a list of matching Clients.
The Clients table is too big to load into an array beforehand this is why I know and understand that this will probably cause the page to be reloaded, but this is OK.

How would I go about doing this?

Anyone has some code sample for me to investigate?

Kind regards
Len
 

add a submit button to the form that when clicked submits the form to itself.
use the info typed by the user to run a SELECT statement against the database that will grab the matching info if any from the database and then run a loop to populate the drop down with the data you retrieve.

example

<%@ Language=VBScript %>
<%
If (your textbox) <> Empty Then
strSELECT = &quot;SELECT (whatever) FROM (wherever) &quot;
strWHERE = &quot;WHERE strSurname LIKE '%&quot; & Request(your textbox) & &quot;%'&quot;
strSQL = strSELECT & strWHERE
objRS.CursorLocation = adUseClient
objRS.Open strSQL, objConn
End If
%>

<SELECT>
<OPTION>-Select a Name-</OPTION>
<%
If objRS.RecordCount = 0 Then
Response.Write &quot;Sorry, there are no records in the database that match the specified criteria.<br><br>&quot;
End If
Do While Not objRS.EOF
Response.Write &quot;<OPTION value=&quot; & objRS(&quot;intSurnameID&quot;)
Response.Write objRS(&quot;strSurname&quot;)
Response.Write &quot;</OPTION>
objRS.MoveNext
Loop
objConn.Close
objRS.Close
Set objConn = Nothing
Set objRS = Nothing

%>



 
A second option (IE only) is the old hidden iframe trick. Create a page that accepts the information you would get to search on. Then add a hidden iframe to your page. When the person clicks the link change the location gof the iframe to be the address of your new page qith the variables in the querystring. Then your new page will do the aSP to query the db and write everything out to a javascript array. Use the onload for your new (hidden) page to call a js function back on the main page (window.parent.functionName from hidden frame i think) and pass it your new array.
this is a pain to get working correctly and is very difficult to get working in a browser compliant nature, you would be better resubmitting like above.
-Tarwn &quot;If you eat a live toad first thing in the morning, nothing worse will happen all day long.&quot; - California saying
&quot;To you or the toad&quot; - Niven's restatement of California saying
&quot;-well most of the time anyway...&quot; - programmers caveat to Niven's restatement of California saying
(The Wiz Biz - Ri
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top