Hi friends

First of all I would like to thank people here on Daniweb for helping me whenever I need help. I am hopefull that now also all of you will help me. Today I got a special scenario which I am applying in my application.
I have 2 text boxes to enter zipcode, In first text box when ever user enters some data and presses tab and on getting focus on the second textbox, the second textbox must show data based on the values entered in the first textbox like what we see in google suggest.
For example when user enters 5 digit zipcode in 1st textbox & presses tab key the focus will be on 2nd textbox and immediately 2nd textbox must show names of peoples based on the zipcode entered in 1st textbox, like how we see in google suggest.
For further clarification please mail me back. Hope some one will help me. Thanks in advance

Thanks
wajid

Dani AI

Generated

This is a common UI pattern: a ZIP code is entered in the first field and the second field should immediately surface matching names when focus arrives (for example after Tab). , @bhi and have already pointed to server-backed lookups and server-driven postbacks; the following practical guidance fills gaps around latency, security, and usability while keeping the behavior instant for the user.

A resilient flow: validate the first field as a 5-digit ZIP on blur, then keep a small client-side cache keyed by ZIP. When focus lands in the second field, show cached results immediately if present; otherwise fire a lightweight request for a short list (limit to ~10 entries). A prefetch-on-blur strategy gives the fastest perceived response because most users tab directly into the next field. Include a brief loading state so keyboard users know a lookup is in progress.

Server-side notes: return a compact JSON array, limit results, and ensure the ZIP lookup is indexed for performance. Always use parameterized queries or stored procedures to prevent SQL injection and never return unnecessary personal data. Rate-limit or throttle the endpoint if large volumes are expected. For implementation patterns and secure query practices, see the OWASP guidance on SQL injection prevention: SQL Injection Prevention Cheat Sheet.

UX and accessibility: display suggestions as an ARIA-compliant list (combobox/autocomplete pattern), allow keyboard arrow navigation and Enter to pick an item, show a clear “no matches” message, and clear stale suggestions if the ZIP changes. For simple projects, the native HTML5 datalist is a low-effort option; for richer keyboard/ARIA support consider a proven widget such as jQuery UI Autocomplete. Useful references: datalist - MDN and the WAI‑ARIA autocomplete pattern in the ARIA Authoring Practices.

Recommended Answers

All 3 Replies

i guess u can use webservices to achive this functionality

I think this can be done by setting autopostback of the 1st text box to true.

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Me.TextBox1.AutoPostBack = True
    End Sub

Protected Sub TextBox1_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
        If (Me.TextBox1.Text = "whatever text required") Then
            Me.TextBox2.Text = "whatever text should appear in 2nd text box"
        End If
    End Sub

This should work. Try it

Umm... I think you should maintain a database of 'suggests' for showing them in the 2nd TextBox

As @bhi said, enable the autopostback property for the 1st textbox and do this-

"Select * from <table> where <field> like" & me.textbox1.text & "%"

This sql is for the 'suggests'. If you need some other field, just modify your sql statement.

Bind the result of this query to your multi-line 2nd textbox.

You can do this in AJAX too.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.