473,881 Members | 1,629 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Populate Pull down menu from access database on selection of previous pull down menu

46 New Member
Hello Experts.
Could you find a solution for this problem please!

I have the following tables in Access Database

Table Name: origin
Fields Names: country, countrycode

Table Name: make
Fields Names: countrycode, make


Table Name: toyota
Fields Name: model

Table Name: nissan
Fields Name: model

Table Name: mazda
Fields Name: model


I want to design a form in ASP where users can choose the specification of his car from a series of pull down menus.


There are 4 Pull down menus/Combo boxes as follows:

Combo box 1: Origin [populates data from table origin]

Combo box 2: Make [populates data from table make]
Initially disabled. Once an element is selected in combo box 1, combo box 2 is enabled and is populated with data corresponding to that item from table make.

Combo box 3: Model [populate data from a table chosen from the list specified in combo box 2]
Initially disabled. Once an element is selected in combo box 2, combo box 3 is enabled and is populated with data corresponding to that item. For example, if a user select Toyota in combo box 2, then combo box 3 is automatically populated with data from table Toyota that is, Corolla, Vitz, Allion, Corona etc..


Combo box 4: Capacity [populate data from a table chosen from the list specified in combo box 3]
Initially disabled. Once an element is selected in combo box 3, combo box 4 is enabled and is populated with data corresponding to that item.


I have given it a try
Here are my codes

Expand|Select|Wrap|Line Numbers
  1.  
  2. <%@ Language = VBscript %>
  3. <% Option Explicit %>
  4. <% Response.Buffer = True %>
  5.  
  6. <html>
  7. <head>
  8. <title>Search Your Car</title>
  9. <SCRIPT language=JavaScript>
  10. function reload(form){
  11. var strval=form.make.options[form.make.options.selectedIndex].value;
  12. self.location='car.asp?make=' +str val ;
  13. }
  14. </script>
  15.  
  16. <SCRIPT language=JavaScript>
  17. function reload(form1){
  18. var strval1=form1.make.options[form1.make.options.selectedIndex].value;
  19. self.location='car.asp?make=' + strval1 ;
  20. }
  21. </script>
  22.  
  23. </head><body>
  24.  
  25. <%
  26. Dim objconn,objRS,strSQL,make
  27. make=Request.QueryString("make")
  28. Set objconn = Server.CreateObject("ADODB.Connection")
  29. objconn.ConnectionString = "DRIVER=Microsoft Access Driver (*.mdb);DBQ=" & Server.MapPath("yeshti.mdb")
  30. objconn.Open
  31.  
  32. Set objRs = Server.CreateObject("ADODB.Recordset")
  33.  
  34. ‘The First drop down Menu/Combo Box'
  35.  
  36. strSQL = "SELECT * from origin"
  37. objRS.Open strSQL, objconn
  38. Response.Write "<form method=post name=f1 action=''><select name=country onchange='reload(this.form)'><option value=''>Select origin</option>"
  39. Do While Not objRS.EOF 
  40.     Response.Write "<option value=" & objRs("country") & ">" & objRs("country") & "</option>"
  41.      objRS.MoveNext
  42.  Loop
  43. objRs.Close
  44. Response.Write "</select>"
  45. Response.Write "<br>----<br>"
  46.  
  47.  
  48. ‘ Second drop down menu
  49.  
  50. If len(country) > 1 Then
  51.  
  52. strSQL = "SELECT  * FROM make where countrycode='" & countrycode &"'"
  53. objRS.Open strSQL, objconn
  54. Response.Write "<select name=make onchange='reload(this.form1)'><option value=''>Select origin</option>"
  55. Do While Not objRS.EOF 
  56.     Response.Write  objRs("make") & "<br>"
  57.      objRS.MoveNext
  58.  Loop
  59. Response.Write "</Select>"
  60. objRs.Close
  61.  
  62. objconn.Close
  63. end if 
  64.  
  65.      %>
  66. </body>
  67. </html>
  68.  
  69.  
Sir, I am stuck. I do not know how to proceed. I really need your help!
May 14 '08 #1
5 4014
omerbutt
638 Contributor
hi giandeo,
first of all have you any experience regarding AJAX.if yes then i can give you a more managed way to do it and more efficient too,apart from if you know javascript , its same like it
regards,
omer
May 14 '08 #2
giandeo
46 New Member
hi giandeo,
first of all have you any experience regarding AJAX.if yes then i can give you a more managed way to do it and more efficient too,apart from if you know javascript , its same like it
regards,
omer
No sir, I do not know AJAX, I am new to programming. I am learning ASP and Javascript.
May 14 '08 #3
omerbutt
638 Contributor
No sir, I do not know AJAX, I am new to programming. I am learning ASP and Javascript.
its a good practice to start your javascript in ajax its same as javascript here
http://www.w3schools.com/ajax/ajax_intro.asp just have an over view it would open a new era of solutions to your problems,come back when you have gone through these pages then i tell you how to make that work with your code and you will be amazed to see such efficient and accurate results, don worry thats for just to have an idea that what AJAX is actually :)
regards,
omer
May 14 '08 #4
giandeo
46 New Member
its a good practice to start your javascript in ajax its same as javascript here
http://www.w3schools.com/ajax/ajax_intro.asp just have an over view it would open a new era of solutions to your problems,come back when you have gone through these pages then i tell you how to make that work with your code and you will be amazed to see such efficient and accurate results, don worry thats for just to have an idea that what AJAX is actually :)
regards,
omer
Thank you so much for your suggestions Sir. I am going to have a look about how AJAX works and will soon report to you.
May 15 '08 #5
omerbutt
638 Contributor
Thank you so much for your suggestions Sir. I am going to have a look about how AJAX works and will soon report to you.
:) any time giandeo, feel free to ask
regards,
omer.
May 16 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

3
11241
by: julian | last post by:
hi I was wondering if anyone can help me out on this.... I have dynamcally populated a drop down menu with data from an access database using ASP. The values seem fine, however when i pass them to the next page (using form get method) the whitespaces in the values are ignored. For example with <option value=jim jones> then only "jim" gets passed to the next page not "jim jones". I have viewed the source created on the dynamic page and...
6
15428
by: Greg Scharlemann | last post by:
I am attempting to populate a drop down menu based on the selection of a different drop down menu. However, it is not working correctly, I cannot figure out for the life of me what exactly happens because I am not getting any errors on the page. <html> <script language="javascript"> var phaseArray = new phaseArray(4); var phaseTypeId = new phaseTypeId(4); var phaseId = new phaseId(4);
1
6369
by: Greg Scharlemann | last post by:
I would like to automatically populate a drop down menu when the page loads based on the selection of an item in a different drop down menu. I made a test page that when drop down #1 changes, drop down #2 populates. Does anyone know how to get drop down #2 to populate based on what is selected in drop down #1 when the page loads? Here is my test code: ************************************************************************ <html>...
0
560
by: guidopapinino | last post by:
What I want to do is have 2 pull down lists, for example a state pull down list and a city pull down list. What I would like to have done is when you select a state from the state pull down list then the city pull down list will populate with all the cities from that selected state. I know that is a lot of data but that is just an example. Or something like when you are looking up cars online they have a make pull down list and a model...
1
2604
by: rajarameshvarma | last post by:
Hi, I have two user controls in an asp.net webpage each contains a DropDownList. Depending on the selection of the drop down in one user control i need to populate data in the other drop down which is in another usercontrol in the same page. Autopostback property for the first dropsown is set to true. please anybody can help me in this regard .
5
17689
by: joshua.nicholes | last post by:
I have an access database that consists of two tables.A data collection table and a species list table. The data collection table has about 1500 records in it and the species list has about 600. The species list has 7 fields the first is a four digit unique identifier (species) it is set as the primary key. I have created a relationship to the data collection table which also has a species field (4 digit id). In my form I have the species...
1
4013
by: SkipNRun | last post by:
I am a novice when comes to JavaScript, AJAX. I am working on a form, which will allow users to update their contact information. In order to make the form flexible, I need to use pull down list. Depends on the pull down list selection, I use script.aculo.us to validate the user input before submit and pass the necessary data, such as contact type, contact information and ranking to a php program for updating. This form should allow multiple...
21
2921
by: giandeo | last post by:
Hello Experts. Is it possible to retrieve the value from a populated pull down menu from a database and then use that value to access the same database to get the related fields. Example: Database name: sp Table: importer Field names: imp_code, imp_name, imp_address, imp_tel
1
1698
by: KMEscherich | last post by:
Platform = Windows Program = Access 2003 Hi there, I am stumpped!! I am attempting to populate a form control as follows: I have a form that has 2 drop-down boxes. One retrieves the EMP_ID and the 2nd one retrieves the EMP_NAME and EMP_ID.
0
9776
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11098
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10814
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10401
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7953
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5781
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5977
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4597
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4196
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.