PDA

Click to See Complete Forum and Search --> : Dynamically FIll in Forms


blindlizard
Apr 30th, 2001, 11:41 PM
How can I dynamically fill in text boxes and combo boxes from values entered by a user in other text boxes without loading a new page or clicking a submit button? This would be simple in VB with events, but I don't know enough VBScript or JavaScript. Thanks.

blindlizard
May 1st, 2001, 09:46 AM
The fields are all on the same form. I.e. There are 2 text boxes and a combo box on a form. The user puts their id number in the first box, and the second box automatically fillis in their name and the combo box selects their country - without the user doing anything more than puting in their id and hiting tab.

monte96
May 1st, 2001, 10:58 AM
Hmm... you would have to have your alot of your database on the client side to do that most likely.. You would do that by using client side arrays that have foriegn keys to each other as one of their elements.

Maybe I'm unclear what your asking.. but if you mean can the user login without a round trip to the server, then for security reasons I would say NO. You don't want those parts of the database on the client side.

In VB you would access the database in an event and populate the other controls. Not as easy on the web because the page is on the client side and the database is on the server side.

The only other option is to use call the page with a querystring of the user's ID. You can check for the querystring in the top of the page and if found do the necessary database lookups and populate things when the page refreshes.

rsitogp
May 1st, 2001, 10:58 AM
Here is the outline: add a webbrowser control to a form.
Private Sub Form_Load()
WebBrowser1.Navigate "www.thesiteyouneed.com"
End Sub

Private Sub WebBrowser1_DownloadComplete()
If WebBrowser1.LocationURL = "www.thesiteyouneed.com" Then
WebBrowser1.Document.FORMNAMEGOESHERE.TEXTBOXNAMEGOESHERE.Value = "the value you want"
End Sub

blindlizard
May 1st, 2001, 01:15 PM
Well I don't mide having all the values when the page first loads, but I only want the client to see certain values based on what the input into the first text box without loading a new page. I thought there may be some JavaScript to do this.

monte96
May 1st, 2001, 01:54 PM
The problem is that you would have to have a 2 dimensional array containing a record for each ID and what information each ID has associated with it. Each record will need to have a field that matches to a value in the combo box so that value can be 'selected'. If you have alot of users, this becomes a bit much to send across the net.

blindlizard
May 1st, 2001, 02:06 PM
That's not really my concern. I just want to be able to fill in fields for the user, if I have the information. To keep them from having to enter the information themselves. There are only a few users. They are filling out a form that will be printed. I guess like an invoice. I don't want them to have to enter data I already have in the database.

monte96
May 1st, 2001, 03:26 PM
Um.. then why have it on the form at all? Just get it from the database when the form gets submitted and display it on a summary page that has all of the data they entered along with any data that is only from the database.

I mean, I can give you an example of looping through the recordset to create the dynamic client side script that creates the arrays, but it really sounds like your doing this the hard way.