Wrox Programmer Forums
|
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 29th, 2006, 12:38 PM
Authorized User
 
Join Date: Dec 2004
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default Fill field based on another field

I have a input form with 5 fields. One of the fields is MajorNo and the other is named Description.

I have a reference table in my MS Access database (tblMajor)that lists the major numbers and their descriptions.

I would like to have the description field in my ASP automatically filled based on the major number entered on the form, so the user will only need to input the major number when submitting to the Access table (tblSalesTotal).

Please help!!

Thanks.

 
Old December 29th, 2006, 01:37 PM
Friend of Wrox
 
Join Date: May 2006
Posts: 643
Thanks: 0
Thanked 0 Times in 0 Posts
Default

What type of input fields are these? Is the user typing text into the field, or are these select dropdowns? How many tblMajor records are there?

Are you wishing to dynamically populate the Description field as the user enters or changes values in the MajorNo field, or only after the user submits the post?

Woody Z
http://www.learntoprogramnow.com
 
Old December 29th, 2006, 03:01 PM
Authorized User
 
Join Date: Dec 2004
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The MajorNo field is a dropdown list and the description field is a text box. There are about 9 different major numbers.

 
Old December 30th, 2006, 11:02 AM
Friend of Wrox
 
Join Date: May 2006
Posts: 643
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Since there are only 9 different major numbers, this is a very simple situation. There are several ways to deal with this.

It should be understood that the description can be extracted from tblMajor and should never need to be input by the user.

The easiest, and very likely the best solution, would be to display both the MajorNo and Description together in the MagorNo dropdown. To do this you merely need to concatenate the values as you retreive them from the database or as you add them as options in the dropdown.

Another approach is to add some javascript code to hold the descriptions, and a way to map the descriptions to the majorNo - which could be done with an array or other mechanism. You would then need to handle the click or change or whatever event (you will have to determine the correct event) of the Major Number dropdown with a little javascript to display the description of the currently selected Major Number.

An overkill approach would be to do this with Ajax. With only 9 major numbers to deal with, it is easy enough to simply pass the data along with each response. If you had thousands of items to deal with, you would probably want to use an Ajax solution.

It probably isn't as important as it used to be, but for any solution using javascript the user will need to have their browser enabled to use scripting. If you don't feel this is likely, or you must provide your page without javascript, then the first solution will still work.

Woody Z
http://www.learntoprogramnow.com





Similar Threads
Thread Thread Starter Forum Replies Last Post
Can I even fill a subform field this way? flora8 Access VBA 13 August 27th, 2007 10:08 AM
Updating a Date field based on another field arholly Access VBA 6 November 22nd, 2006 11:19 AM
auto fill field mankoti_mankoti2000 Access 1 May 26th, 2006 08:19 AM
Create lookup based on field value s.hendy Access 2 May 20th, 2005 04:08 AM
Update city field based on zip field nganb SQL Server ASP 0 April 22nd, 2004 10:30 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.