Hi everyone.
Help with this problem.
With Google I found this script: -
-
var regiondb = new Object()
-
regiondb["Assente"] = [{value:"Ferie", text:"Ferie"},
-
{value:"Festivitą abolita", text:"Festivitą abolita"},
-
{value:"Malattia", text:"Malattia"},
-
{value:"Infortunio", text:"Infortunio"},
-
{value:"Riposo Fisiologico", text:"Riposo Fisiologico"},
-
{value:"Riposo Compensativo", text:"Riposo"},
-
{value:"Permesso retribuito", text:"Permesso"},
-
{value:"Permesso Sind./ARCA", text:"Permesso Sind."},
-
{value:"Ricovero Ospedaliero", text:"Ricovero"},
-
{value:"Part-time", text:"Part-time"},
-
{value:"Assemblea Sindacale", text:"Assemblea"},
-
{value:"Sciopero", text:"Sciopero"},
-
{value:"Aspettativa", text:"Aspettativa"},
-
{value:"Carica Pubblica", text:"Carica Pubblica"},
-
{value:"Da giustificare", text:"Da giustificare"}];
-
-
regiondb["Presente"] = [{value:"Monoperatore", text:"Monoperatore"},
-
{value:"Coppia", text:"Coppia"},
-
{value:"Formazione a tre", text:"Formazione a tre"},
-
{value:"Appoggio", text:"Appoggio"},
-
{value:"Fuori sede", text:"Fuori sede"},
-
{value:"In sede", text:"In sede"}];
-
-
-
function setCities(chooser) {
-
var newElem;
-
var where = (navigator.appName == "Microsoft Internet Explorer") ? -1 : null;
-
var cityChooser = chooser.form.elements["tipo_stato_giornaliero"];
-
while (cityChooser.options.length) {
-
cityChooser.remove(0);
-
}
-
var choice = chooser.options[chooser.selectedIndex].value;
-
var db = regiondb[choice];
-
newElem = document.createElement("option");
-
newElem.text = "Seleziona valore";
-
newElem.value = "";
-
cityChooser.add(newElem, where);
-
if (choice != "") {
-
for (var i = 0; i < db.length; i++) {
-
newElem = document.createElement("option");
-
newElem.text = db[ i ].text;
-
newElem.value = db[ i ].value;
-
cityChooser.add(newElem, where);
-
}
-
}
-
-
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: -
-
<option value="Fuori Sede">Fuori Sede</option>
-
<option value="In Sede">In Sede</option>
-
I select the value Presente ( variable B ) from select Choose a Region :
2) When the variable is B in select Choose a City is: -
-
<option value="Coppia">Coppia</option>
-
<option value="Formazione a tre">Formazione a tre</option>
-
<option value="Appoggio">Appoggio</option>
-
<option value="Fuori Sede">Fuori Sede</option>
-
<option value="In Sede">In Sede</option>
-
Is possible?
Regards,
Viki
72 5330
Yes, it's possible.
What problems are you having with implementing it?
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...
Use the onchange event handler to change the city drop down.
Use the onchange event handler to change the city drop down.
Sorry Acoder.... not understand... for example ?
[HTML]<select name="region" onchange="setCities(this)">[/HTML] You may need to change the values in the array to the options that you want displayed.
Is already planned in this script: -
-
var regiondb = new Object()
-
regiondb["Assente"] = [{value:"Ferie", text:"Ferie"},
-
{value:"Festivitą abolita", text:"Festivitą abolita"},
-
{value:"Malattia", text:"Malattia"},
-
{value:"Infortunio", text:"Infortunio"},
-
{value:"Riposo Fisiologico", text:"Riposo Fisiologico"},
-
{value:"Riposo Compensativo", text:"Riposo"},
-
{value:"Permesso retribuito", text:"Permesso"},
-
{value:"Permesso Sind./ARCA", text:"Permesso Sind"},
-
{value:"Ricovero Ospedaliero", text:"Ricovero"},
-
{value:"Part-time", text:"Part-time"},
-
{value:"Assemblea Sindacale", text:"Assemblea"},
-
{value:"Sciopero", text:"Sciopero"},
-
{value:"Aspettativa", text:"Aspettativa"},
-
{value:"Carica Pubblica", text:"Carica Pubblica"},
-
{value:"Da giustificare", text:"Da giustificare"}];
-
-
regiondb["Presente"] = [{value:"Monoperatore", text:"Monoperatore"},
-
{value:"Coppia", text:"Coppia"},
-
{value:"Formazione a tre", text:"Formazione a tre"},
-
{value:"Appoggio", text:"Appoggio"},
-
{value:"Fuori sede", text:"Fuori sede"},
-
{value:"In sede", text:"In sede"}];
-
-
-
function setCities(chooser) {
-
var newElem;
-
var where = (navigator.appName == "Microsoft Internet Explorer") ? -1 : null;
-
var cityChooser = chooser.form.elements["tipo_stato_giornaliero"];
-
while (cityChooser.options.length) {
-
cityChooser.remove(0);
-
}
-
var choice = chooser.options[chooser.selectedIndex].value;
-
var db = regiondb[choice];
-
newElem = document.createElement("option");
-
newElem.text = "Seleziona valore";
-
newElem.value = "";
-
cityChooser.add(newElem, where);
-
if (choice != "") {
-
for (var i = 0; i < db.length; i++) {
-
newElem = document.createElement("option");
-
newElem.text = db[i].text;
-
newElem.value = db[i].value;
-
cityChooser.add(newElem, where);
-
}
-
}
-
-
-
....
-
-
<select name="stato_dipendente" onchange="setCities(this)">
-
<option>Seleziona stato giornaliero</option>
-
<option value="Assente">Assente</option>
-
<option value="Presente">Presente</option>
-
</select></td>
-
-
<select name="tipo_stato_giornaliero" onchange="onChangeStatus(this);"><option>Seleziona tipo stato giornaliero</option>
-
</select>
-
-
In this script implement variable A or B.
Oh, I see.
You will need to create separate arrays, e.g. - regiondb["PresenteA"] = [{value:"Fuori sede", text:"Fuori sede"},
-
{value:"In sede", text:"In sede"}];
-
regiondb["PresenteB"] = [{value:"Monoperatore", text:"Monoperatore"},
-
{value:"Coppia", text:"Coppia"},
-
{value:"Formazione a tre", text:"Formazione a tre"},
-
{value:"Appoggio", text:"Appoggio"},
-
{value:"Fuori sede", text:"Fuori sede"},
-
{value:"In sede", text:"In sede"}];
-
-
-
function setCities(chooser) {
-
...
-
var choice = chooser.options[chooser.selectedIndex].value;
-
var db = regiondb[choice+regionVar]; // regionVar is A or B
Sorry... but:
Error: 'regionVar' is undefined
:(
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.
Right, but not easy explain here...
The idea is select presente from the select name stato_dipendente : -
<select name="stato_dipendente" onchange="setCities(this)">
-
<option>Seleziona stato giornaliero</option>
-
<option value="Assente">Assente</option>
-
<option value="Presente">Presente</option>
-
</select></td>
-
When select presente in the select name stato_dipendente, sending variable as the function setCities.
The function setCities receives this variable and in the select name tipo_stato_giornaliero :
1) Variable A ===> regiondb["PresenteA"]
2) Variable B ===> regiondb["PresenteB"]
thanks for your help...
That still doesn't explain when A becomes B or vice versa.
If you keep a global variable, you don't even need to pass the variable in the onchange function.
1) The variable is A when in select D1 is selected value DVD or value DVDR .
2) The variable is B when in select D1 is selected value CDR or value CD . -
-
-
<select size="8" name="D1" multiple>
-
<option>Select</option>
-
<option value="A-DVD">DVD</option>
-
<option value="A-DVDR">DVDR</option>
-
<option value="B-CDR">CDR</option>
-
<option value="B-CD">CD</option>
-
</select>
-
-
My page htm this: -
<html>
-
-
<head>
-
-
<script language="javascript">
-
-
<!--
-
-
var regiondb = new Object()
-
regiondb["Assente"] = [{value:"Ferie", text:"Ferie"},
-
{value:"Festivitą abolita", text:"Festivitą abolita"},
-
{value:"Malattia", text:"Malattia"},
-
{value:"Infortunio", text:"Infortunio"},
-
{value:"Riposo Fisiologico", text:"Riposo Fisiologico"},
-
{value:"Riposo Compensativo", text:"Riposo"},
-
{value:"Permesso retribuito", text:"Permesso"},
-
{value:"Permesso Sind./ARCA", text:"Permesso Sind"},
-
{value:"Ricovero Ospedaliero", text:"Ricovero"},
-
{value:"Part-time", text:"Part-time"},
-
{value:"Assemblea Sindacale", text:"Assemblea"},
-
{value:"Sciopero", text:"Sciopero"},
-
{value:"Aspettativa", text:"Aspettativa"},
-
{value:"Carica Pubblica", text:"Carica Pubblica"},
-
{value:"Da giustificare", text:"Da giustificare"}];
-
-
regiondb["PresenteA"] = [{value:"Fuori sede", text:"Fuori sede"},
-
{value:"In sede", text:"In sede"}];
-
-
regiondb["PresenteB"] = [{value:"Monoperatore", text:"Monoperatore"},
-
{value:"Coppia", text:"Coppia"},
-
{value:"Formazione a tre", text:"Formazione a tre"},
-
{value:"Appoggio", text:"Appoggio"},
-
{value:"Fuori sede", text:"Fuori sede"},
-
{value:"In sede", text:"In sede"}];
-
-
-
function setCities(chooser)
-
-
{
-
var newElem;
-
var where = (navigator.appName == "Microsoft Internet Explorer") ? -1 : null;
-
var cityChooser = chooser.form.elements["tipo_stato_giornaliero"];
-
while (cityChooser.options.length)
-
-
{
-
cityChooser.remove(0);
-
}
-
-
var choice = chooser.options[chooser.selectedIndex].value;
-
var db = regiondb[choice+regionVar]; // regionVar is A or B
-
-
newElem = document.createElement("option");
-
newElem.text = "Seleziona valore";
-
newElem.value = "";
-
cityChooser.add(newElem, where);
-
if (choice != "")
-
-
{
-
for (var i = 0; i < db.length; i++)
-
-
{
-
newElem = document.createElement("option");
-
newElem.text = db[ i ].text;
-
newElem.value = db[ i ].value;
-
cityChooser.add(newElem, where);
-
}
-
}
-
-
}
-
-
// -->
-
-
</script>
-
-
</head>
-
-
<body>
-
-
<form method="POST" action="page.asp">
-
-
<select size="8" name="D1" multiple onChange="window.document.location='select.htm?var='+this.options[this.selectedIndex].value+'';">
-
<option>Select</option>
-
<option value="A-DVD">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">Presente</option>
-
</select></td>
-
-
<select name="tipo_stato_giornaliero" onchange="onChangeStatus(this);">
-
<option>Seleziona tipo stato giornaliero</option>
-
</select>
-
-
</form>
-
-
</body>
-
-
</html>
-
-
1) The variable is A when in select D1 is selected value DVD or value DVDR .
2) The variable is B when in select D1 is selected value CDR or value CD . -
<select size="8" name="D1" multiple>
-
<option>Select</option>
-
<option value="A-DVD">DVD</option>
-
<option value="A-DVDR">DVDR</option>
-
<option value="B-CDR">CDR</option>
-
<option value="B-CD">CD</option>
-
</select>
-
The idea is select presente from the select name stato_dipendente : -
<select name="stato_dipendente" onchange="setCities(this)">
-
<option>Seleziona stato giornaliero</option>
-
<option value="Assente">Assente</option>
-
<option value="Presente">Presente</option>
-
</select></td>
-
When select presente in the select name stato_dipendente, sending variable as the function setCities.
The function setCities receives this variable and in the select name tipo_stato_giornaliero :
1) Variable A ===> regiondb["PresenteA"]
2) Variable B ===> regiondb["PresenteB"]
The error is: Error: 'regionVar' is undefined
Link page: http://www12.asphost4free.com/viki1967/select.htm
thanks for your help...
You'll have to set regionVar to avoid the error. You could call it anything really.
Now, the select element is multiple. What if the user selects both A and B type options?
Another thing to look at is the value of the options. Can these just be "A" or "B"? If they can, then good. If not, I can show you how to get the value.
What you need to do is give the select element an id and then use document.getElementById(whatever-ID-name-you-chose) to get the element. If it's a single type select, you can just use .value to get the value. If it's a multiple, you will need to loop over to get the selected option values. Set this to regionVar (or whatever variable name you want) and you're ready to go.
Now, the select element is multiple. What if the user selects both A and B type options?
It's not possible; necesary control in the select name D1 only valid value A OR value B, not value A AND value B.
Can these just be "A" or "B"?
Yes only value A or value B, nothing more.
Thanks for your help.
Yes only value A or value B, nothing more.
By this, I meant here: -
<option value="A-DVD">DVD</option>
-
<option value="A-DVDR">DVDR</option>
-
<option value="B-CDR">CDR</option>
-
<option value="B-CD">CD</option>
could it be - <option value="A">DVD</option>
-
<option value="A">DVDR</option>
-
<option value="B">CDR</option>
-
<option value="B">CD</option>
?
Not, because in the page.asp do this: -
strD1 = Split(request.form("D1"), "-")
-
and insert the value Split strD1(0) and strD1(1) in the database...
It' s necessary: -
-
<option>Select</option>
-
<option value="A-DVD">DVD</option>
-
<option value="A-DVDR">DVDR</option>
-
<option value="B-CDR">CDR</option>
-
<option value="B-CD">CD</option>
-
</select>
-
-
That's OK, just use the JavaScript string split() method here too. - regionVar = val.split("-")[0];
where val is the value of the selected option.
-
function setCities(chooser)
-
-
{
-
var newElem;
-
var where = (navigator.appName == "Microsoft Internet Explorer") ? -1 : null;
-
var cityChooser = chooser.form.elements["tipo_stato_giornaliero"];
-
while (cityChooser.options.length)
-
-
{
-
cityChooser.remove(0);
-
}
-
-
var regionVar = D1.split("-")[0];
-
-
var choice = chooser.options[chooser.selectedIndex].value;
-
var db = regiondb[choice+regionVar]; // regionVar is A or B
-
-
newElem = document.createElement("option");
-
newElem.text = "Seleziona valore";
-
newElem.value = "";
-
cityChooser.add(newElem, where);
-
if (choice != "")
-
-
{
-
for (var i = 0; i < db.length; i++)
-
-
{
-
newElem = document.createElement("option");
-
newElem.text = db[ i ].text;
-
newElem.value = db[ i ].value;
-
cityChooser.add(newElem, where);
-
}
-
}
-
-
}
The error is: Error: 'D1' is undefined
[php]
<html>
<%
Session.LCID = 1040
response.expires = -1500
response.AddHeader "PRAGMA", "NO-CACHE"
response.CacheControl = "PRIVATE"
Function SELECTED(firstVal, secondVal())
For e = 0 To UBound(secondVal)
If cSTR(firstVal) = cSTR(secondVal(e)) then
SELECTED = " selected=""selected"""
End If
Next
End Function
%>
<head>
<script language="javascript">
<!--
var regiondb = new Object()
regiondb["Assente"] = [{value:"Ferie", text:"Ferie"},
{value:"Festivitą abolita", text:"Festivitą abolita"},
{value:"Malattia", text:"Malattia"},
{value:"Infortunio", text:"Infortunio"},
{value:"Riposo Fisiologico", text:"Riposo Fisiologico"},
{value:"Riposo Compensativo", text:"Riposo"},
{value:"Permesso retribuito", text:"Permesso"},
{value:"Permesso Sind./ARCA", text:"Permesso Sind"},
{value:"Ricovero Ospedaliero", text:"Ricovero"},
{value:"Part-time", text:"Part-time"},
{value:"Assemblea Sindacale", text:"Assemblea"},
{value:"Sciopero", text:"Sciopero"},
{value:"Aspettativa", text:"Aspettativa"},
{value:"Carica Pubblica", text:"Carica Pubblica"},
{value:"Da giustificare", text:"Da giustificare"}];
regiondb["PresenteA"] = [{value:"Fuori sede", text:"Fuori sede"},
{value:"In sede", text:"In sede"}];
regiondb["PresenteB"] = [{value:"Monoperatore", text:"Monoperatore"},
{value:"Coppia", text:"Coppia"},
{value:"Formazione a tre", text:"Formazione a tre"},
{value:"Appoggio", text:"Appoggio"},
{value:"Fuori sede", text:"Fuori sede"},
{value:"In sede", text:"In sede"}];
function setCities(chooser)
{
var newElem;
var where = (navigator.appName == "Microsoft Internet Explorer") ? -1 : null;
var cityChooser = chooser.form.elements["tipo_stato_giornaliero"];
while (cityChooser.options.length)
{
cityChooser.remove(0);
}
// regionVar
var regionVar = document.getElementById('reg').split("-")[0];
var choice = chooser.options[chooser.selectedIndex].value;
var db = regiondb[choice+regionVar]; // regionVar is A or B
newElem = document.createElement("option");
newElem.text = "Seleziona valore";
newElem.value = "";
cityChooser.add(newElem, where);
if (choice != "")
{
for (var i = 0; i < db.length; i++)
{
newElem = document.createElement("option");
newElem.text = db[i].text;
newElem.value = db[i].value;
cityChooser.add(newElem, where);
}
}
}
// -->
</script>
</head>
<body>
<form method="POST" action="page.asp">
<select size="8" id="reg" name="SelectMultipla" multiple="multiple">
<%
valore_strVariabile = Request.QueryString("SelectMultipla")
If len(valore_strVariabile) = 0 then
%>
<option>Select</option>
<option value="A-DVD">DVD</option>
<option value="A-DVDR">DVDR</option>
<option value="B-CDR">CDR</option>
<option value="B-CD">CD</option>
<%
Else
If InStr(valore_strVariabile,",") > 0 then
valore_strVariabile = Replace(valore_strVariabile," ","")
elementi = split(valore_strVariabile,",")
Else
elementi = array(valore_strVariabile)
End If
%>
<option>Select</option>
<option value="A-DVD" <%=SELECTED("A-DVD", elementi)%>>DVD</option>
<option value="A-DVDR" <%=SELECTED("A-DVDR", elementi)%>>DVDR</option>
<option value="B-CDR" <%=SELECTED("B-CDR", elementi)%>>CDR</option>
<option value="B-CD" <%=SELECTED("B-CD", elementi)%>>B-CDR</option>
<% End If %>
</select>
<select name="stato_dipendente" onchange="setCities(this)">
<option>Seleziona stato giornaliero</option>
<option value="Assente">Assente</option>
<option value="Presente">Presente</option>
</select></td>
<select name="tipo_stato_giornaliero" onchange="onChangeStatus(this);">
<option>Seleziona tipo stato giornaliero</option>
</select>
<input type="submit" value="vai" />
</form>
</body>
</html>
[/php]
Error is: Object doens't support this property or method
:(
Error is: Object doens't support this property or method
:(
I see you got rid of the first error. This error is caused by you calling split on the actual select element rather than a string.
You need to get the selected option value and then call split on that.
To get the selected option, loop over the options of the select and get the options which are selected (options[i].selected == true).
I see you got rid of the first error. This error is caused by you calling split on the actual select element rather than a string.
You need to get the selected option value and then call split on that.
To get the selected option, loop over the options of the select and get the options which are selected (options[i].selected == true).
Sorry Acoder.... not understand... what include the string selected (options[i].selected == true) ?
To get the selected options of a multiple select: - for (i=0; i < document.getElementById('reg').options.length; i++) {
-
if (document.getElementById('reg').options[i].selected == true) {
-
val = options[i].value; // you may try something else here depending on how many options can be selected...
-
}
-
}
Once you have the value (which is a string), you can call split() on it.
Sorry, but iam not sure understand... not work...
[php]
function setCities(chooser)
{
var newElem;
var where = (navigator.appName == "Microsoft Internet Explorer") ? -1 : null;
var cityChooser = chooser.form.elements["tipo_stato_giornaliero"];
while (cityChooser.options.length)
{
cityChooser.remove(0);
}
// regionVar
var regionVar = document.getElementById('reg').split("-")[0];
for (i=0; i < document.getElementById('reg').options.length; i++) {
if (document.getElementById('reg').options[i].selected == true) {
val = options[i].value;
}
}
var choice = chooser.options[chooser.selectedIndex].value;
var db = regiondb[choice+regionVar]; // regionVar is A or B
newElem = document.createElement("option");
newElem.text = "Seleziona valore";
newElem.value = "";
cityChooser.add(newElem, where);
if (choice != "")
{
for (var i = 0; i < db.length; i++)
{
newElem = document.createElement("option");
newElem.text = db[i].text;
newElem.value = db[i].value;
cityChooser.add(newElem, where);
}
}
}
[/php]
You'll need to get rid of the var regionVar... line. Replace val with regionVar, e.g. - var regionVar = "";
-
var reg = document.getElementById("reg");
-
for (i=0; i < reg.options.length; i++) {
-
if (reg.options[i].selected == true) {
-
if (regionVar == "") regionVar = reg.options[i].value;
-
}
-
}
Thanks, but change the error: Error: 'lenght' is null or not an object
[php]
<html>
<%
Session.LCID = 1040
response.expires = -1500
response.AddHeader "PRAGMA", "NO-CACHE"
response.CacheControl = "PRIVATE"
Function SELECTED(firstVal, secondVal())
For e = 0 To UBound(secondVal)
If cSTR(firstVal) = cSTR(secondVal(e)) then
SELECTED = " selected=""selected"""
End If
Next
End Function
%>
<head>
<script language="javascript">
<!--
function onChangeStatus(dayStatusObj)
{
// Oggetto FORM
var frmObj = dayStatusObj.form;
// Se il dipendente č fuori sede o in sede, abilita 'fuori_sede' e 'Note_fuori_sede'
var flEnabled = true;
if (dayStatusObj.value == "Monoperatore") flEnabled = false;
if (dayStatusObj.value == "Coppia") flEnabled = false;
if (dayStatusObj.value == "Formazione a tre") flEnabled = false;
if (dayStatusObj.value == "Appoggio") flEnabled = false;
if (dayStatusObj.value == "Fuori sede") flEnabled = false;
}
var regiondb = new Object()
regiondb["Assente"] = [{value:"Ferie", text:"Ferie"},
{value:"Festivitą abolita", text:"Festivitą abolita"},
{value:"Malattia", text:"Malattia"},
{value:"Infortunio", text:"Infortunio"},
{value:"Riposo Fisiologico", text:"Riposo Fisiologico"},
{value:"Riposo Compensativo", text:"Riposo"},
{value:"Permesso retribuito", text:"Permesso"},
{value:"Permesso Sind./ARCA", text:"Permesso Sind"},
{value:"Ricovero Ospedaliero", text:"Ricovero"},
{value:"Part-time", text:"Part-time"},
{value:"Assemblea Sindacale", text:"Assemblea"},
{value:"Sciopero", text:"Sciopero"},
{value:"Aspettativa", text:"Aspettativa"},
{value:"Carica Pubblica", text:"Carica Pubblica"},
{value:"Da giustificare", text:"Da giustificare"}];
regiondb["PresenteA"] = [{value:"Fuori sede", text:"Fuori sede"},
{value:"In sede", text:"In sede"}];
regiondb["PresenteB"] = [{value:"Monoperatore", text:"Monoperatore"},
{value:"Coppia", text:"Coppia"},
{value:"Formazione a tre", text:"Formazione a tre"},
{value:"Appoggio", text:"Appoggio"},
{value:"Fuori sede", text:"Fuori sede"},
{value:"In sede", text:"In sede"}];
function setCities(chooser)
{
var newElem;
var where = (navigator.appName == "Microsoft Internet Explorer") ? -1 : null;
var cityChooser = chooser.form.elements["tipo_stato_giornaliero"];
while (cityChooser.options.length)
{
cityChooser.remove(0);
}
// regionVar
var regionVar = "";
var reg = document.getElementById("reg");
for (i=0; i < reg.options.length; i++) {
if (reg.options[i].selected == true) {
if (regionVar == "") regionVar = reg.options[i].value;
}
}
// regionVar
var choice = chooser.options[chooser.selectedIndex].value;
var db = regiondb[choice+regionVar]; // regionVar is A or B
newElem = document.createElement("option");
newElem.text = "Seleziona valore";
newElem.value = "";
cityChooser.add(newElem, where);
if (choice != "")
{
for (var i = 0; i < db.length; i++)
{
newElem = document.createElement("option");
newElem.text = db[i].text;
newElem.value = db[i].value;
cityChooser.add(newElem, where);
}
}
}
// -->
</script>
</head>
<body>
<form method="POST" action="page.asp">
<select size="8" id="reg" name="SelectMultipla" multiple="multiple">
<%
valore_strVariabile = Request.QueryString("SelectMultipla")
If len(valore_strVariabile) = 0 then
%>
<option>Select</option>
<option value="A-DVD">DVD</option>
<option value="A-DVDR">DVDR</option>
<option value="B-CDR">CDR</option>
<option value="B-CD">CD</option>
<%
Else
If InStr(valore_strVariabile,",") > 0 then
valore_strVariabile = Replace(valore_strVariabile," ","")
elementi = split(valore_strVariabile,",")
Else
elementi = array(valore_strVariabile)
End If
%>
<option>Select</option>
<option value="A-DVD" <%=SELECTED("A-DVD", elementi)%>>DVD</option>
<option value="A-DVDR" <%=SELECTED("A-DVDR", elementi)%>>DVDR</option>
<option value="B-CDR" <%=SELECTED("B-CDR", elementi)%>>CDR</option>
<option value="B-CD" <%=SELECTED("B-CD", elementi)%>>B-CDR</option>
<% End If %>
</select>
<select name="stato_dipendente" onchange="setCities(this)">
<option>Seleziona stato giornaliero</option>
<option value="Assente">Assente</option>
<option value="Presente">Presente</option>
</select></td>
<select name="tipo_stato_giornaliero">
<option>Seleziona tipo stato giornaliero</option>
</select>
<input type="submit" value="vai" />
</form>
</body>
</html>
[/php]
Heh, you checked too soon! I've changed my post- have a look.
Heh, you checked too soon! I've changed my post- have a look.
OK;
Thanks, but change the error: Error: 'lenght' is null or not an object
lenght should be spelt length. Find the line with the error and correct it.
lenght should be spelt length. Find the line with the error and correct it.
Ok, this is:
[php]
// regionVar
var regionVar = "";
var reg = document.getElementById("reg");
for (i=0; i < reg.options.length; i++) {
if (reg.options[i].selected == true) {
if (regionVar == "") regionVar = reg.options[i].value;
}
}
// regionVar
var choice = chooser.options[chooser.selectedIndex].value;
var db = regiondb[choice+regionVar]; // regionVar is A or B
newElem = document.createElement("option");
newElem.text = "Seleziona valore";
newElem.value = "";
cityChooser.add(newElem, where);
if (choice != "")
{
for (var i = 0; i < db.length; i++) <==== ERROR LENGHT
{
newElem = document.createElement("option");
newElem.text = db[i].text;
newElem.value = db[i].value;
cityChooser.add(newElem, where);
}
}
[/php]
Sorry, forgot about the splitting: - // regionVar
-
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;
-
}
-
}
-
// regionVar
Added a break to break out of the loop once selected option found.
This length error is most likely caused by db not being defined because you didn't choose an option or you chose the default option (not Assente/Presente) : -
var choice = chooser.options[chooser.selectedIndex].value;
-
var db = regiondb[choice+regionVar]; // regionVar is A or B
-
-
newElem = document.createElement("option");
-
newElem.text = "Seleziona valore";
-
newElem.value = "";
-
cityChooser.add(newElem, where);
-
if (choice != "" && regionVar != "")
-
-
This solution, but it is right? : -
-
var regiondb = new Object()
-
regiondb["AssenteA"] = [{value:"Ferie", text:"Ferie"},
-
{value:"Festivitą abolita", text:"Festivitą abolita"},
-
{value:"Malattia", text:"Malattia"},
-
{value:"Infortunio", text:"Infortunio"},
-
{value:"Riposo Fisiologico", text:"Riposo Fisiologico"},
-
{value:"Riposo Compensativo", text:"Riposo"},
-
{value:"Permesso retribuito", text:"Permesso"},
-
{value:"Permesso Sind./ARCA", text:"Permesso Sind"},
-
{value:"Ricovero Ospedaliero", text:"Ricovero"},
-
{value:"Part-time", text:"Part-time"},
-
{value:"Assemblea Sindacale", text:"Assemblea"},
-
{value:"Sciopero", text:"Sciopero"},
-
{value:"Aspettativa", text:"Aspettativa"},
-
{value:"Carica Pubblica", text:"Carica Pubblica"},
-
{value:"Da giustificare", text:"Da giustificare"}];
-
-
regiondb["AssenteB"] = [{value:"Ferie", text:"Ferie"},
-
{value:"Festivitą abolita", text:"Festivitą abolita"},
-
{value:"Malattia", text:"Malattia"},
-
{value:"Infortunio", text:"Infortunio"},
-
{value:"Riposo Fisiologico", text:"Riposo Fisiologico"},
-
{value:"Riposo Compensativo", text:"Riposo"},
-
{value:"Permesso retribuito", text:"Permesso"},
-
{value:"Permesso Sind./ARCA", text:"Permesso Sind"},
-
{value:"Ricovero Ospedaliero", text:"Ricovero"},
-
{value:"Part-time", text:"Part-time"},
-
{value:"Assemblea Sindacale", text:"Assemblea"},
-
{value:"Sciopero", text:"Sciopero"},
-
{value:"Aspettativa", text:"Aspettativa"},
-
{value:"Carica Pubblica", text:"Carica Pubblica"},
-
{value:"Da giustificare", text:"Da giustificare"}];
-
-
regiondb["PresenteA"] = [{value:"Fuori sede", text:"Fuori sede"},
-
{value:"In sede", text:"In sede"}];
-
-
regiondb["PresenteB"] = [{value:"Monoperatore", text:"Monoperatore"},
-
{value:"Coppia", text:"Coppia"},
-
{value:"Formazione a tre", text:"Formazione a tre"},
-
{value:"Appoggio", text:"Appoggio"},
-
{value:"Fuori sede", text:"Fuori sede"},
-
{value:"In sede", text:"In sede"}];
-
-
So this variable A or B is only for Presente?
You could keep it like your previous post if in future you plan to add A/B options for Assente too. If not, add some code to check the choice is not "Assente" when adding regionVar, i.e. the line - var db = regiondb[choice+regionVar]; // regionVar is A or B
should only be for "Presente". If choice is "Assente", don't add regionVar: - if (choice == "Presente") choice += regionVar;
-
var db = regiondb[choice];
Thanks.
Yes, this variable A or B is only for value Presente
With last changes when Assente displays alert('db empty').
[php]
function setCities(chooser)
{
var newElem;
var where = (navigator.appName == "Microsoft Internet Explorer") ? -1 : null;
var cityChooser = chooser.form.elements["tipo_stato_giornaliero"];
while (cityChooser.options.length)
{
cityChooser.remove(0);
}
// regionVar
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;
}
}
// regionVar
var choice = chooser.options[chooser.selectedIndex].value;
if (choice == "Presente") choice += regionVar;
var db = regiondb[choice];
//var db = regiondb[choice+regionVar]; // regionVar is A or B
if(typeof(db) == 'undefined') {
alert('db empty');
return;
}
newElem = document.createElement("option");
newElem.text = "Seleziona valore";
newElem.value = "";
cityChooser.add(newElem, where);
if (choice != "" && regionVar != "")
{
for (var i = 0; i < db.length; i++)
{
newElem = document.createElement("option");
newElem.text = db[i].text;
newElem.value = db[i].value;
cityChooser.add(newElem, where);
}
}
}
[/php]
Change regiondb["AssenteA"] back to regiondb["Assente"].
You're welcome. Phew! One long thread this one.
You're welcome. Phew! One long thread this one.
Yes, long thread but very interesting....
Hi, i have new problem..
Please follow this sequence in this page web: http://www.complessobandisticopalomb...967/select.asp
1) No selection in the select name="SelectMultipla";
2) Select value Assente in the select name="stato_dipendente";
3) The select name="tipo_stato_giornaliero" is empty.
1) No selection in the select name="SelectMultipla";
2) Select value Presente in the select name="stato_dipendente";
3) The alert window warning db empty.
You can see alert window warning when value Assente is selected in the select name="stato_dipendente" ???
Thanks...
Lol, you're back!
That seems easy enough to solve. Just add an entry for "Presente" (maybe something empty) in the regiondb array.
Thanks, !
Sorry, but iam not understand...
I modify this code:? -
if(typeof(db) == 'undefined') {
-
alert('db empty');
-
return;
-
...
[php]
<html>
<head>
<script language="javascript">
<!--
var regiondb = new Object()
regiondb["Assente"] = [{value:"Ferie", text:"Ferie"},
{value:"Festivitą abolita", text:"Festivitą abolita"},
{value:"Malattia", text:"Malattia"},
{value:"Infortunio", text:"Infortunio"},
{value:"Riposo Fisiologico", text:"Riposo Fisiologico"},
{value:"Riposo Compensativo", text:"Riposo"},
{value:"Permesso retribuito", text:"Permesso"},
{value:"Permesso Sind./ARCA", text:"Permesso Sind"},
{value:"Ricovero Ospedaliero", text:"Ricovero"},
{value:"Part-time", text:"Part-time"},
{value:"Assemblea Sindacale", text:"Assemblea"},
{value:"Sciopero", text:"Sciopero"},
{value:"Aspettativa", text:"Aspettativa"},
{value:"Carica Pubblica", text:"Carica Pubblica"},
{value:"Da giustificare", text:"Da giustificare"}];
regiondb["PresenteA"] = [{value:"Fuori sede", text:"Fuori sede"},
{value:"In sede", text:"In sede"}];
regiondb["PresenteB"] = [{value:"Monoperatore", text:"Monoperatore"},
{value:"Coppia", text:"Coppia"},
{value:"Formazione a tre", text:"Formazione a tre"},
{value:"Appoggio", text:"Appoggio"},
{value:"Fuori sede", text:"Fuori sede"},
{value:"In sede", text:"In sede"}];
function setCities(chooser)
{
var newElem;
var where = (navigator.appName == "Microsoft Internet Explorer") ? -1 : null;
var cityChooser = chooser.form.elements["tipo_stato_giornaliero"];
while (cityChooser.options.length)
{
cityChooser.remove(0);
}
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(typeof(db) == 'undefined') {
alert('db empty');
return;
}
newElem = document.createElement("option");
newElem.text = "Seleziona valore";
newElem.value = "";
cityChooser.add(newElem, where);
if (choice != "" && regionVar != "")
{
for (var i = 0; i < db.length; i++)
{
newElem = document.createElement("option");
newElem.text = db[i].text;
newElem.value = db[i].value;
cityChooser.add(newElem, where);
}
}
}
// -->
</script>
</head>
<body>
<form method="POST" action="page.asp">
<select size="8" id="reg" name="SelectMultipla" multiple="multiple">
<option>Select</option>
<option value="A-DVD">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">Presente</option>
</select></td>
<select name="tipo_stato_giornaliero">
<option>Seleziona tipo stato giornaliero</option>
</select>
<input type="submit" value="vai" />
</form>
</body>
</html>
[/php]
Add: - regiondb["Presente"] = [];
Add: - regiondb["Presente"] = [];
Thanks Acoder, but not change....
[php]
<html>
<head>
<script language="javascript">
<!--
var regiondb = new Object()
regiondb["Assente"] = [{value:"Ferie", text:"Ferie"},
{value:"Festivitą abolita", text:"Festivitą abolita"},
{value:"Malattia", text:"Malattia"},
{value:"Infortunio", text:"Infortunio"},
{value:"Riposo Fisiologico", text:"Riposo Fisiologico"},
{value:"Riposo Compensativo", text:"Riposo"},
{value:"Permesso retribuito", text:"Permesso"},
{value:"Permesso Sind./ARCA", text:"Permesso Sind"},
{value:"Ricovero Ospedaliero", text:"Ricovero"},
{value:"Part-time", text:"Part-time"},
{value:"Assemblea Sindacale", text:"Assemblea"},
{value:"Sciopero", text:"Sciopero"},
{value:"Aspettativa", text:"Aspettativa"},
{value:"Carica Pubblica", text:"Carica Pubblica"},
{value:"Da giustificare", text:"Da giustificare"}];
regiondb["PresenteA"] = [{value:"Fuori sede", text:"Fuori sede"},
{value:"In sede", text:"In sede"}];
regiondb["PresenteB"] = [{value:"Monoperatore", text:"Monoperatore"},
{value:"Coppia", text:"Coppia"},
{value:"Formazione a tre", text:"Formazione a tre"},
{value:"Appoggio", text:"Appoggio"},
{value:"Fuori sede", text:"Fuori sede"},
{value:"In sede", text:"In sede"}];
regiondb["PresenteA"] = [];
regiondb["PresenteB"] = [];
function setCities(chooser)
{
var newElem;
var where = (navigator.appName == "Microsoft Internet Explorer") ? -1 : null;
var cityChooser = chooser.form.elements["tipo_stato_giornaliero"];
while (cityChooser.options.length)
{
cityChooser.remove(0);
}
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(typeof(db) == 'undefined') {
alert('db empty');
return;
}
newElem = document.createElement("option");
newElem.text = "Seleziona valore";
newElem.value = "";
cityChooser.add(newElem, where);
if (choice != "" && regionVar != "")
{
for (var i = 0; i < db.length; i++)
{
newElem = document.createElement("option");
newElem.text = db[i].text;
newElem.value = db[i].value;
cityChooser.add(newElem, where);
}
}
}
// -->
</script>
</head>
<body>
<form method="POST" action="page.asp">
<select size="8" id="reg" name="SelectMultipla" multiple="multiple">
<option>Select</option>
<option value="A-DVD">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">Presente</option>
</select></td>
<select name="tipo_stato_giornaliero">
<option>Seleziona tipo stato giornaliero</option>
</select>
<input type="submit" value="vai" />
</form>
</body>
</html>
[/php]
You've rewritten PresenteA/B with these two lines: -
regiondb["PresenteA"] = [];
-
regiondb["PresenteB"] = [];
Replace them with: -
regiondb["Presente"] = [];
You've rewritten PresenteA/B with these two lines: -
regiondb["PresenteA"] = [];
-
regiondb["PresenteB"] = [];
Replace them with: -
regiondb["Presente"] = [];
Thanks Acoder, but i not explain...
If select value Presente in the select name="stato_dipendente" I see : -
if(typeof(db) == 'undefined') {
-
alert('db empty');
-
return;
-
If select value Assente in the select name="stato_dipendente" I NOT see : -
if(typeof(db) == 'undefined') {
-
alert('db empty');
-
return;
-
The window alert it necessary for two cases....
Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
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...
|
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...
|
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...
|
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....
|
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...
|
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...
|
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...
|
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...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
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...
|
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,...
|
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,...
|
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...
| |