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

Prefill form fields based off information from one field J & VBScript

Status
Not open for further replies.

ceeleelewis

Programmer
Sep 26, 2002
45
US
Hello,

I have an application (service request app) in which users will fill out a form to submit information for a machine(s) that that will require our team's services. Everything is fine except the fact that I will have repeat users on this system. To make the the process easier for my users, I would like have a function that can (onBlur)prefill the information in fields for previous users of the application so when a user types their id, all the fields will be filled with information stored in Access dB.

Since I know that everything will be triggered by the onBlur function. When I psuedo code what I'm trying to accomplish it should look some like this

dbConnection

if onBlur validation = true then prefill

else if false then user fill in fields

the onBlur function will validate the data.

is this the right approach? If not than can someone show me an example of a script that prefills form values based off the info on one field?

Any direction will be greatly appreciated.
 
Please post this in the javascript forum. ________________________________________________________________________
Are you trying to debug your ASP applications? See faq333-3255 for more details

regards,
Brian
 
I've done something similar recently, filling in a supplier address if one existed or allowing the user to fill one in if it did not.

I called a Javascript function from the onChange event on a supplier list. It basically set a couple of hidden variables within the form and submitted to itself.

Then test the value of the request.form variable you set and if necessary, look for and display the data.

Hope this makes sense (sorry if it doesn't, but I had a very long day yesterday). I've included sample code below to try and illustrate.

Regards,

Mark

function submitChange() {
document.<formname>.sAction.value=&quot;AddData&quot;;
document.<formname>.intChanged.value=1;
document.<formname>.submit();
}

function submitForm() {
// run data validation //
document.<formname>.sAction.value=&quot;SubmitData&quot;;
document.<formname>.submit();
}

' then in the body

If Action = &quot;AddData&quot; Then
%><form action=&quot;<filename.asp&quot;> method=&quot;post&quot; name=&quot;<name>&quot;>
<input type=&quot;hidden&quot; name=&quot;intChanged&quot; value=&quot;0&quot;>
<input type=&quot;hidden&quot; name=&quot;sAction&quot; value=&quot;AddData&quot;>
' field below (user ID?) fires of javascript code above
' to submit form
<input type=.. name=&quot;txtUser&quot; onChange=&quot;submitChange()&quot;
<%If request.form(&quot;intChanged&quot;) = 1 Then
' get data from DB and fill in required fields
Else
' leave blank and display fields
End If
%><input type=&quot;button&quot; .. onClick=&quot;return submitForm()&quot;>
</form>
<%

ElseIf Action = &quot;SubmitData&quot; Then
' submit to database

End If
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top