473,614 Members | 2,321 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Javascript - AutoPopulating fields

4 New Member
Hi,

I need to autopopulate a second field based on the info that i have selected from a drop down box in the first field. I need to write both fields back to a SQL database... EXAMPLE:

Field A has a list of counties
Field B has a list of capital cities

I want to select Ireland from the dropt down in field 1 and field 2 should autopopulate with Dublin. The values of the fields have to be:
Field 1 = IRELAND
Field 2 = DUBLIN

Can anybody pls help :cool:

Thanks,
Feb 20 '06 #1
3 3654
Banfa
9,065 Recognized Expert Moderator Expert
When you say a second field what do you mean?
An HTML element or the SQL database?
Which SQL database are you using?
What scripting lanuage are you using for your server side script?
What is the layout of your code?

Remember example code answers a whole bunch of questions that you will otherwise have to explicitly answer.

(I have assumed that since you are using JavaScript we are taking about a web page but you have not stated it).
Feb 21 '06 #2
russr
4 New Member
When you say a second field what do you mean?
An HTML element or the SQL database?
Which SQL database are you using?
What scripting lanuage are you using for your server side script?
What is the layout of your code?

Remember example code answers a whole bunch of questions that you will otherwise have to explicitly answer.

(I have assumed that since you are using JavaScript we are taking about a web page but you have not stated it).


Hi ... Many thanks for the response.
You are correct...It is a webpage.
- When i say field, i am refering to a textarea on a html form.
- The SQL Database is MS SQL - Not sure which version
- Scripting is done using Java and Javascript
I have tried some code already but it has failed dismally... So i have no working code to show you an example of :(


I am using a webpage to write data back to a SQL Database. All the fields that i need are already in the SQL database. When i submit/save my html form, it writes the data that is currently stored in the fields to the SQL database.

What i need is as follows: I want to put a drop down box on my HTML form. So, when using the form, i want to select an option from the drop down list and have the next two/three fields autopopulate information based on the drop down box eg:

Drop Down box containsa list of cities
Field 1 (Text Area 1) Needs to hold city as selected in the drop down box
Field 2 (Text Area 2) Should autopopulate the country where the city is i.e Ireland
Field 3 (Text Area 3) Should autopopulate the country's timezone ie. GMT

I know that i need to have the lists somewhere (i.e. - If the drop down selection is dublin, Country=Ireland , Timezone=GMT, but where i have them, how i refer to them and how i write the values to the next 3 fields is where i'm stuck



Your help is really appreciated with this.

Thanks, :confused:
Feb 23 '06 #3
acoder
16,027 Recognized Expert Moderator MVP
I know that i need to have the lists somewhere (i.e. - If the drop down selection is dublin, Country=Ireland , Timezone=GMT, but where i have them, how i refer to them and how i write the values to the next 3 fields is where i'm stuck
You can use arrays that have been populated during page load from the server-side, or use Ajax to return a delimited string which you can split.
Jun 21 '08 #4

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

Similar topics

9
2698
by: varois83 | last post by:
Hi Newbie here. I have been working on creating a guestbook for my site as practice and am learning a lot. Do you guys validate your forms first on the client with javascript and then on the server with PHP or just use one of the two and if yes which one? I don't want to reinvent the wheel too much. Thanks a lot
0
7063
by: Gowhera Hussain | last post by:
Use This for Learning Only .... Do Not Try To Act Smart HACKING WITH JAVASCRIPT Dr_aMado Sun, 11 Apr 2004 16:40:13 UTC This tutorial is an overview of how javascript can be used to bypass simple/advanced html forms and how it can be used to override cookie/session
6
6078
by: nate | last post by:
Hello, Does anyone know where I can find an ASP server side script written in JavaScript to parse text fields from a form method='POST' using enctype='multipart/form-data'? I'd also like it to parse the filename. <form name='form1' method='POST' enctype='multipart/form-data' action='sub.asp'> <input type='text' name='title1' value='value1'> <input type='file' name='file1'>
3
12870
by: Angel | last post by:
Hi, I have a page which shows a matrix of names and grades for given period. All the grades fields must be editable and they can be up to 200 fields (20 students with 10 grades each) Since there are a lots of fields I do not want to go back and forth to validate entered values on any change. I decided that this may be achieved with some JavaScript functions to validate some controls and to calculate average and total values of other...
5
3253
by: lvroye | last post by:
I have a table of about 6000 clients which have unique client numbers. I am creating a data entry form to log contacts with the clients. I want the client information (Name, Sales Rep, phone number, etc) to autopopulate fields on the form when the client number is entered. I have seen this done on another database I have access to, but have been unseccessfull in recreating it. Can anyone point me in the right direction?
28
2403
by: CatrionnaRain | last post by:
Hi All - I'm using 2002 and consider myself an intermediate Access user but newbie programmer :) I've been tasked with the db project from hell and have been combing through posts for the last week looking for relevant snippets. The problem is that my problem is multi-tiered and although I've seen hints I haven't yet come across anything like this problem. So - without further ado here's the situation. I've got a db that has 3 tables. ...
1
3362
by: anniefs | last post by:
hi help me i m so much stuck int he code and i have no time .... i used ASP VBscipt and javascript functions with MS database javascript function add records in MS DB by using ASP vbscript recordset varible when user click the save button then some values save in the database so i write javascript function to add the records... here is the code
2
2783
by: mdock | last post by:
Hello, I have a javascript grid on my ASP page which displays information about the history of specific units produced in our manufacturing facility. One of the results is the order number on which the unit was shipped. If the unit was not shipped, obviously there is no order number; the default value of this field on the data table is 0. Herein lies the problem; if the order number is 0, I do not want the grid to display anything. If...
2
1477
by: haft | last post by:
My webpage of discussion contains a javascript powered image gallery of small thumbnail images that when moused-over, display a larger image that corresponds to the current moused-over thumbnail. An image caption (whose value is populated by my alt_img database field), also changes according to the current moused-over thumbnail image. All functions fine...except...for the initial value for the alt_jmg database field. The caption text for...
0
8197
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8142
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
8640
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
8287
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,...
1
6093
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
4058
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
4136
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2573
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
0
1438
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.