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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Auto populate textboxes with database information

Status
Not open for further replies.

wendyowens

Programmer
Jan 27, 2003
9
0
0
US
I have a form that has a table that contains a textbox where the user inputs a part number. Depending on what the user enters, when the user tabs to the next textbox, I want it to go to the database and search for the number that was entered. If found, I want it to populate other textboxes with information found for that item in the database. How can I accomplish this??
Thanks
 
I have a form that has a table that contains a textbox where the user inputs a part number. Depending on what the user enters, when the user tabs to the next textbox, I want it to go to the database and search for the number that was entered.
-----------------------------------------------
okey, what has to happen is the page has to refresh. using a javascript command you can submit a form. I suck at javascript, but this is what has needs to happen (resemblance to actual code will be minimal)

OnLostFocus of form.searchfield {
if search field is not empty then submit form
}

Say your page is search.cfm .. the forms action is set to "search.cfm". At the top of the page you setup a little block of code:

<cfparam name = &quot;pagestate&quot; value = &quot;load&quot;>
<cfif pagestate eq search> RUN THE QUERY HERE </cfif>

In the form you include a hidden field called pagestate value=&quot;search&quot;. So when you js function kicks the form back to the server, it will run your search. Then you use the result of the query to populate the other fields if it returns any info about the part.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top