473,445 Members | 1,929 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Select combobox Region ==> City

263 100+
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
72 5337
acoder
16,027 Expert Mod 8TB
Oh, I see! I thought you wanted to get rid of the alert for "Presente".

The reason why you don't see the alert for Assente is that it's defined. To get around that, either create duplicates AssenteA and AssenteB and get rid of Assente, then change the code to add regionVar to 'choice' all the time (not just with "Presente"), OR (for an easier and probably better solution) rather than check that db is defined, just check that regionVar is not empty.
Apr 8 '08 #51
viki1967
263 100+
Oh, I see! I thought you wanted to get rid of the alert for "Presente".

The reason why you don't see the alert for Assente is that it's defined. To get around that, either create duplicates AssenteA and AssenteB and get rid of Assente, then change the code to add regionVar to 'choice' all the time (not just with "Presente"), OR (for an easier and probably better solution) rather than check that db is defined, just check that regionVar is not empty.
Ok, i write:

[php]
var regionVar = "";
var reg = document.getElementById("reg");
for (i=0; i < reg.options.length; i++) {
if (reg.options[i].selected) {
regionVar = reg.options[i].value.split("-")[0];
break;
}
}

var choice = chooser.options[chooser.selectedIndex].value;

if (choice == "Presente") choice += regionVar;
var db = regiondb[choice];

if(regionVar != null) {
alert('KO');
return;
}
[/php]

But the regionVar is ever null....
Apr 8 '08 #52
acoder
16,027 Expert Mod 8TB
Not null, empty:
Expand|Select|Wrap|Line Numbers
  1. if (regionVar != "") {
Apr 8 '08 #53
viki1967
263 100+
Not null, empty:
Expand|Select|Wrap|Line Numbers
  1. if (regionVar != "") {
Not work, try it :

http://www.complessobandisticopalomb...967/select.asp
Apr 8 '08 #54
acoder
16,027 Expert Mod 8TB
Sorry, that should be the other way round:
Expand|Select|Wrap|Line Numbers
  1. if (regionVar == "") {
Apr 8 '08 #55
viki1967
263 100+
Sorry, that should be the other way round:
Expand|Select|Wrap|Line Numbers
  1. if (regionVar == "") {
Many thanks Acoder....

[php]
if(regionVar == "") {
alert('KO');
location.href="select.asp"
return;
}
[/php]

I hope close now.... thanks...
Apr 8 '08 #56
acoder
16,027 Expert Mod 8TB
Many thanks Acoder....
You're welcome again!

[php]
if(regionVar == "") {
alert('KO');
location.href="select.asp"
return;
}
[/php]
Why reload the page?

I hope close now.
Probably not, LOL!
Apr 8 '08 #57
viki1967
263 100+
You're welcome again!

Why reload the page?


Probably not, LOL!
Because I do not this effect:

http://www.complessobandisticopalomb...67/select2.asp

Apr 8 '08 #58
acoder
16,027 Expert Mod 8TB
Then you do away with that by adding the option first before making the regionVar check:
Expand|Select|Wrap|Line Numbers
  1. newElem = document.createElement("option");
  2.     newElem.text = "Seleziona valore";
  3.     newElem.value = "";
  4.     cityChooser.add(newElem, where);
Apr 9 '08 #59
viki1967
263 100+
Then you do away with that by adding the option first before making the regionVar check:
Expand|Select|Wrap|Line Numbers
  1. newElem = document.createElement("option");
  2.     newElem.text = "Seleziona valore";
  3.     newElem.value = "";
  4.     cityChooser.add(newElem, where);
sorry, i do not understand your data...
Apr 9 '08 #60
acoder
16,027 Expert Mod 8TB
Swap that code and the regionVar check around:
Expand|Select|Wrap|Line Numbers
  1. var regionVar = "";
  2. var reg = document.getElementById("reg");
  3. for (i=0; i < reg.options.length; i++) {
  4.     if (reg.options[i].selected) {
  5.         regionVar = reg.options[i].value.split("-")[0];
  6.         break;
  7.     }
  8. }
  9.  
  10.     var choice = chooser.options[chooser.selectedIndex].value;
  11.  
  12.     if (choice == "Presente") choice += regionVar;
  13.     var db = regiondb[choice];
  14.  
  15.     newElem = document.createElement("option");
  16.     newElem.text = "Seleziona valore";
  17.     newElem.value = "";
  18.     cityChooser.add(newElem, where);
  19.  
  20.     if (regionVar == "") {
  21.       alert("KO");
  22.       return;
  23.     }
  24.  
  25.     if (choice != "" && regionVar != "")
  26.  
Apr 9 '08 #61
viki1967
263 100+
Thanks again Acoder !!!!
Apr 9 '08 #62
acoder
16,027 Expert Mod 8TB
You're welcome yet again!
Apr 10 '08 #63
viki1967
263 100+
You're welcome yet again!
Hi my friend Acoder.... I still... :-)

It is possible when you invoke the page select.asp have this situation ?



You explain:

1) in the select name="SelectMultipla" preselected first value of the list ( in this example = DVD );

2) in the select name="stato_dipendente" preselected value Presente;

3) in the select name="stato_dipendente" values Fuori sede and In sede;

Thanks for your help...
viki
Apr 11 '08 #64
acoder
16,027 Expert Mod 8TB
1) in the select name="SelectMultipla" preselected first value of the list ( in this example = DVD );

2) in the select name="stato_dipendente" preselected value Presente;

3) in the select name="stato_dipendente" values Fuori sede and In sede;
No need for JavaScript, though you could use JavaScript too.

Just add selected to the options that need preselecting:
Expand|Select|Wrap|Line Numbers
  1. <option value="A-DVD" selected>DVD</option>
For the third select, just put the options in the HTML code.
Apr 11 '08 #65
viki1967
263 100+
No need for JavaScript, though you could use JavaScript too.

Just add selected to the options that need preselecting:
Expand|Select|Wrap|Line Numbers
  1. <option value="A-DVD" selected>DVD</option>
For the third select, just put the options in the HTML code.
Thanks, i have:

[php]

<select size="8" id="reg" name="SelectMultipla" multiple="multiple">

<option>Select</option>
<option value="A-DVD" selected>DVD</option>
<option value="A-DVDR">DVDR</option>
<option value="B-CDR">CDR</option>
<option value="B-CD">CD</option>

</select>


<select name="stato_dipendente" onchange="setCities(this)">
<option>Seleziona stato giornaliero</option>
<option value="Assente">Assente</option>
<option value="Presente" selected>Presente</option>
</select></td>

<select name="tipo_stato_giornaliero">
<option>Seleziona tipo stato giornaliero</option>
</select>


[/php]


But the third select is empty.... not values In sede and Fuori sede...

http://www.complessobandisticopalomb...67/select2.asp
Apr 11 '08 #66
acoder
16,027 Expert Mod 8TB
Yes, add them yourself in the HTML:
Expand|Select|Wrap|Line Numbers
  1. <select name="tipo_stato_giornaliero">
  2.     <option>Seleziona tipo stato giornaliero</option>
  3.     <option>In sede</option>
  4.     <option>Fuori sede</option>
  5. </select>
Apr 11 '08 #67
viki1967
263 100+
Yes, add them yourself in the HTML:
Expand|Select|Wrap|Line Numbers
  1. <select name="tipo_stato_giornaliero">
  2.     <option>Seleziona tipo stato giornaliero</option>
  3.     <option>In sede</option>
  4.     <option>Fuori sede</option>
  5. </select>
Many thanks again... again mi friend Acoder... ;-)
Apr 11 '08 #68
acoder
16,027 Expert Mod 8TB
Glad to help!
Apr 11 '08 #69
viki1967
263 100+
Glad to help!

This is historic post with many answers... is unique post with many answers ?
Apr 11 '08 #70
acoder
16,027 Expert Mod 8TB
It has a number of different threads of discussion relating to the same problem, so yeah, maybe unique in that respect, but some threads in the Access forum are pretty long with many contributors.

Hope others find it useful too.
Apr 11 '08 #71
viki1967
263 100+
It has a number of different threads of discussion relating to the same problem, so yeah, maybe unique in that respect, but some threads in the Access forum are pretty long with many contributors.

Hope others find it useful too.

You are welcome and I'am very happy to found this Community !!!
Apr 11 '08 #72
acoder
16,027 Expert Mod 8TB
Glad to hear it.

I think we'll leave it there, otherwise this thread could become a lot longer than it already is ;)
Apr 12 '08 #73

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

Similar topics

18
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...
1
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...
9
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...
0
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...
7
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....
2
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...
9
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...
2
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...
2
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
1
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...
0
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,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.