473,806 Members | 2,253 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Select combobox Region ==> City

263 Contributor
Hi everyone.

Help with this problem.

With Google I found this script:

Expand|Select|Wrap|Line Numbers
  1.  
  2. var regiondb = new Object()
  3. regiondb["Assente"] = [{value:"Ferie", text:"Ferie"},
  4.                       {value:"Festività abolita", text:"Festività abolita"},
  5.                       {value:"Malattia", text:"Malattia"},
  6.                       {value:"Infortunio", text:"Infortunio"},
  7.                       {value:"Riposo Fisiologico", text:"Riposo Fisiologico"},
  8.                       {value:"Riposo Compensativo", text:"Riposo"},
  9.                       {value:"Permesso retribuito", text:"Permesso"},
  10.                       {value:"Permesso Sind./ARCA", text:"Permesso Sind."},
  11.                       {value:"Ricovero Ospedaliero", text:"Ricovero"},
  12.                       {value:"Part-time", text:"Part-time"},
  13.                       {value:"Assemblea Sindacale", text:"Assemblea"},
  14.                       {value:"Sciopero", text:"Sciopero"},
  15.                       {value:"Aspettativa", text:"Aspettativa"},
  16.                       {value:"Carica Pubblica", text:"Carica Pubblica"},
  17.                       {value:"Da giustificare", text:"Da giustificare"}];
  18.  
  19. regiondb["Presente"] = [{value:"Monoperatore", text:"Monoperatore"},
  20.                         {value:"Coppia", text:"Coppia"},
  21.                         {value:"Formazione a tre", text:"Formazione a tre"},
  22.                         {value:"Appoggio", text:"Appoggio"},
  23.                         {value:"Fuori sede", text:"Fuori sede"},
  24.                         {value:"In sede", text:"In sede"}];
  25.  
  26.  
  27. function setCities(chooser) {
  28.     var newElem;
  29.     var where = (navigator.appName == "Microsoft Internet Explorer") ? -1 : null;
  30.     var cityChooser = chooser.form.elements["tipo_stato_giornaliero"];
  31.     while (cityChooser.options.length) {
  32.         cityChooser.remove(0);
  33.     }
  34.     var choice = chooser.options[chooser.selectedIndex].value;
  35.     var db = regiondb[choice];
  36.     newElem = document.createElement("option");
  37.     newElem.text = "Seleziona valore";
  38.     newElem.value = "";
  39.     cityChooser.add(newElem, where);
  40.     if (choice != "") {
  41.         for (var i = 0; i < db.length; i++) {
  42.             newElem = document.createElement("option");
  43.             newElem.text = db[ i ].text;
  44.             newElem.value = db[ i ].value;
  45.             cityChooser.add(newElem, where);
  46.         }
  47.     }
  48.  
  49.  
I change this way:

Have a variable ( associated with the selected value from select Choose a Region ), which can be A or B.

I select the value Presente ( variable A ) from select Choose a Region :

1) When the variable is A, in select Choose a City is:

Expand|Select|Wrap|Line Numbers
  1.  
  2. <option value="Fuori Sede">Fuori Sede</option>
  3. <option value="In Sede">In Sede</option>
  4.  
I select the value Presente ( variable B ) from select Choose a Region :

2) When the variable is B in select Choose a City is:

Expand|Select|Wrap|Line Numbers
  1.  
  2. <option value="Coppia">Coppia</option>
  3. <option value="Formazione a tre">Formazione a tre</option>
  4. <option value="Appoggio">Appoggio</option>
  5. <option value="Fuori Sede">Fuori Sede</option>
  6. <option value="In Sede">In Sede</option>
  7.  
Is possible?

Regards,
Viki
Apr 3 '08 #1
72 5511
acoder
16,027 Recognized Expert Moderator MVP
Yes, it's possible.

What problems are you having with implementing it?
Apr 3 '08 #2
viki1967
263 Contributor
Yes, it's possible.

What problems are you having with implementing it?
Thanks for your answer.

My problem is:
I not have idea to set this variable A o B in this script...
Apr 3 '08 #3
acoder
16,027 Recognized Expert Moderator MVP
Use the onchange event handler to change the city drop down.
Apr 3 '08 #4
viki1967
263 Contributor
Use the onchange event handler to change the city drop down.
Sorry Acoder.... not understand... for example ?
Apr 3 '08 #5
acoder
16,027 Recognized Expert Moderator MVP
[HTML]<select name="region" onchange="setCi ties(this)">[/HTML] You may need to change the values in the array to the options that you want displayed.
Apr 3 '08 #6
viki1967
263 Contributor
Is already planned in this script:

Expand|Select|Wrap|Line Numbers
  1.  
  2. var regiondb = new Object()
  3. regiondb["Assente"] = [{value:"Ferie", text:"Ferie"},
  4.                       {value:"Festività abolita", text:"Festività abolita"},
  5.                       {value:"Malattia", text:"Malattia"},
  6.                       {value:"Infortunio", text:"Infortunio"},
  7.                       {value:"Riposo Fisiologico", text:"Riposo Fisiologico"},
  8.                       {value:"Riposo Compensativo", text:"Riposo"},
  9.                       {value:"Permesso retribuito", text:"Permesso"},
  10.                       {value:"Permesso Sind./ARCA", text:"Permesso Sind"},
  11.                       {value:"Ricovero Ospedaliero", text:"Ricovero"},
  12.                       {value:"Part-time", text:"Part-time"},
  13.                       {value:"Assemblea Sindacale", text:"Assemblea"},
  14.                       {value:"Sciopero", text:"Sciopero"},
  15.                       {value:"Aspettativa", text:"Aspettativa"},
  16.                       {value:"Carica Pubblica", text:"Carica Pubblica"},
  17.                       {value:"Da giustificare", text:"Da giustificare"}];
  18.  
  19. regiondb["Presente"] = [{value:"Monoperatore", text:"Monoperatore"},
  20.                         {value:"Coppia", text:"Coppia"},
  21.                         {value:"Formazione a tre", text:"Formazione a tre"},
  22.                         {value:"Appoggio", text:"Appoggio"},
  23.                         {value:"Fuori sede", text:"Fuori sede"},
  24.                         {value:"In sede", text:"In sede"}];
  25.  
  26.  
  27. function setCities(chooser) {
  28.     var newElem;
  29.     var where = (navigator.appName == "Microsoft Internet Explorer") ? -1 : null;
  30.     var cityChooser = chooser.form.elements["tipo_stato_giornaliero"];
  31.     while (cityChooser.options.length) {
  32.         cityChooser.remove(0);
  33.     }
  34.     var choice = chooser.options[chooser.selectedIndex].value;
  35.     var db = regiondb[choice];
  36.     newElem = document.createElement("option");
  37.     newElem.text = "Seleziona valore";
  38.     newElem.value = "";
  39.     cityChooser.add(newElem, where);
  40.     if (choice != "") {
  41.         for (var i = 0; i < db.length; i++) {
  42.             newElem = document.createElement("option");
  43.             newElem.text = db[i].text;
  44.             newElem.value = db[i].value;
  45.             cityChooser.add(newElem, where);
  46.         }
  47.     }
  48.  
  49.  
  50. ....
  51.  
  52. <select name="stato_dipendente" onchange="setCities(this)">
  53. <option>Seleziona stato giornaliero</option>
  54. <option value="Assente">Assente</option>
  55. <option value="Presente">Presente</option>
  56. </select></td>
  57.  
  58. <select name="tipo_stato_giornaliero" onchange="onChangeStatus(this);"><option>Seleziona tipo stato giornaliero</option>
  59. </select>
  60.  
  61.  
In this script implement variable A or B.
Apr 3 '08 #7
acoder
16,027 Recognized Expert Moderator MVP
Oh, I see.

You will need to create separate arrays, e.g.
Expand|Select|Wrap|Line Numbers
  1. regiondb["PresenteA"] = [{value:"Fuori sede", text:"Fuori sede"},
  2.                         {value:"In sede", text:"In sede"}];
  3. regiondb["PresenteB"] = [{value:"Monoperatore", text:"Monoperatore"},
  4.                         {value:"Coppia", text:"Coppia"},
  5.                         {value:"Formazione a tre", text:"Formazione a tre"},
  6.                         {value:"Appoggio", text:"Appoggio"},
  7.                         {value:"Fuori sede", text:"Fuori sede"},
  8.                         {value:"In sede", text:"In sede"}];
  9.  
  10.  
  11. function setCities(chooser) {
  12. ...
  13.     var choice = chooser.options[chooser.selectedIndex].value;
  14.     var db = regiondb[choice+regionVar]; // regionVar is A or B
Apr 3 '08 #8
viki1967
263 Contributor
Sorry... but:

Error: 'regionVar' is undefined

:(
Apr 3 '08 #9
acoder
16,027 Recognized Expert Moderator MVP
I know, that was just an example. I expected that you'd set it somewhere.

I'm not sure when it has to change. That's not clear from what you've posted so far.
Apr 3 '08 #10

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

Similar topics

18
4066
by: CJM | last post by:
I'm building a search function for one of my applications. The user has the option to enter a number criteria of criteria, but none are compulsary. I need to be able to build up a query string that includes only the right criteria. The simplest way I have found is something like this: sSQL = "Select field1, field2, etc form table where 1=1" If Request.Form("Criteria1") <> "" then sSQL = sSQL & " and criteria1 = " &...
1
3348
by: jtwright | last post by:
I've got a view that creates a parent child relationship, this view is used in Analysis Services to create a dimension in a datastore. This query tends to deadlock after about 10 days of running smoothly. Only way to fix it is to reboot the box, I can recycle the services for a quick fix but that usually only works for the next 1-2 times I call the view. This view is used to create a breakdown of the bill-to locations from...
9
5112
by: Bob Bedford | last post by:
I've a form that use a combobox along with other fields. When the user submit the form, many tests are done. If any test fails, then I show the form again with previously entered values. My problem: when I show back the form with previously entered values, I can't set the entered value of the combobox. I've registered the value, but how to go trough the value, and select the right one. I'd like something like:
0
1924
by: Susan Bricker | last post by:
The following error: "The current field must match the join key '?' in the table that seves as t the 'one' side of one-to-many relationship. Enter a record in the 'one' side table with the desired key value, and then make the entry with the desired join key in the 'many-only' table." ... happens when I click on an entry of a combobox. HELP!! Here's the background:
7
20773
by: charliewest | last post by:
Using .Net CF, i have created a 2 dimension ArrayList, and "binded" this list to a ComboBox control using the "DataSource" property. I have set the DisplaySource and ValueMember properties as well. The control populates well, both the display values, and selected values. However, when i try to "set" the SelectedValue or SelectedIndex properties, nothing happens.... The default blank value in the ComboBox is always selected. My code is: ...
2
1643
by: Becker | last post by:
I have a need for a simple combobox on a form in one of my programs that represents city, state. I want to have it autocomplete as the user types. I have a table with these values (about 50k of them) and I'd like to source it from there. I have seen some methods out there for the autocomplete, but I think that pulling 50k in the combobox might be too slow at runtime to build a table of all those records and then bind the entire combobox...
9
7324
by: Don | last post by:
Is there any way to detect when an item has been added to the Items collection of a combobox or listbox? I am inheriting a Combobox and want to validate items before they are added to the combobox, but I can't find anything that will let me do that. - Don
2
2521
by: John | last post by:
Hi There is a <select name='city'item with <optionin the HTML <form name='france'> I have tried using the following in a JS routine: <a href="javascript:window.opener.document.france.city.options.selected=true; window.close();"></a> I get
2
1737
by: Sudhakar | last post by:
i have two select tags as part of a registration form, city1 city2 where city1 has a list of regions and similar for city2 there are different regions for city1 and city2 so instead of all the regions appearing one after the other i would like to create a blank option followed by the next set of regions for formatting purpose only. ex= <select name="city1">
0
9596
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
10617
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...
0
10364
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10370
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
9186
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7649
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...
1
4328
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
3849
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3008
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.