Problem with "onchange" mehtod

Hello,
I have a problem with the “onchange” of my form.In fact I have three form “combo” type
and I want the second “combo” is sorted according to the content value of the first “combo”, and that the third “combo” is sorted according to the content value of the second “combo” ;

I tried to do it like this:

if(name=="ajouteritineraire")						
						  {								
							dpItineraire2 = new dataProcessor("s_Mission.php");
							dhxWinsItineraire2 = new dhtmlXWindows();
							modalItineraire2= dhxWinsItineraire2.createWindow(1, 550, 300, 530, 180);
							modalItineraire2.setText("Création d'un itinéraire");
							modalItineraire2.setModal(true);
							modalItineraire2.denyResize();
							modalItineraire2.center();
							modalItineraire2.keepInViewport(true);
							FormBtnItineraire2 = modalItineraire2.attachForm(ItineraireData2);
							FormBtnItineraire2.attachEvent("onChange", function(name,value, is_checked)
							{
								//FormBtnItineraire2.load("villeptions2.php?v="+value);
								if (name !== 'modetransport') 
								{
									alert('transport');
									return true;
								}
								depart = FormBtnItineraire2.getCombo('depart');
								depart.load("villeptions2.php?d="+value);
								arrivee = FormBtnItineraire2.getCombo('arrivee');
								arrivee.load("villeptions2.php?a="+depart.getSelectedText());
								return true;
							}
							);}

but it does not work;

Thank you for making me a little support!

Hello
Please, see this topic:
viewtopic.php?f=17&t=33546&p=105215#p105215

thank you,
I’ve seen, but it works stand alone for combo, but my problem is that my combo is integrate in in the Form (dhtmlxform);
that is my complete form.

var ItineraireData2 = 
	[
		{
			type: "settings",
			position: "label-left",
			labelWidth: 100, 
			inputWidth: 120
		},
		{
			type: "fieldset",
			label: "Informations sur l'itinéraire",
			inputWidth: 500,
			list:
			[														
				{
					type: "hidden",										
					name: "idcache",
					value: "-1"
					
				},
				{
					type: "hidden",										
					name: "itineraire",
					value: "save"					
				},									
				{
					id: "modetransport",
					type: "combo",
					inputWidth: 200,
					labelWidth: 200,
					label: "Choisir le mode transport",
					name: "modetransport",
					validate: "NotEmpty",
					//modetransportoptions2.php
					connector: "modetransportoptions2.php",
				},
				{
					id: "depart",
					type: "combo",
					inputWidth: 200,
					labelWidth: 210,
					label: "Ville de départ",
					name: "depart",
					validate: "NotEmpty",
					//villeptions2.php
					//connector: "",
				},
				{
					id: "arrivee",
					type: "combo",
					inputWidth: 200,
					labelWidth: 200,
					label: "Ville de destination",
					name: "arrivee",
					validate: "NotEmpty",
					//villeptions2.php
					//connector: "",
				},							
				{
					type: "button",
					value: "Enregistrer",
					name: "enregistrer"								
				}	
			]
		}
	];

And this is my sort function:

if(name=="ajouteritineraire")						
						  {								
							dpItineraire2 = new dataProcessor("s_Mission.php");
							dhxWinsItineraire2 = new dhtmlXWindows();
							modalItineraire2= dhxWinsItineraire2.createWindow(1, 550, 300, 530, 180);
							modalItineraire2.setText("Création d'un itinéraire");
							modalItineraire2.setModal(true);
							modalItineraire2.denyResize();
							modalItineraire2.center();
							modalItineraire2.keepInViewport(true);
							FormBtnItineraire2 = modalItineraire2.attachForm(ItineraireData2);
							FormBtnItineraire2.attachEvent("onChange", function(name,value, is_checked)
							{
								//FormBtnItineraire2.load("villeptions2.php?v="+value);
								if (name !== 'modetransport') 
								{
									alert('transport');
									return true;
								}
								alert(dhtmlXComboFromSelect('depart'));
								depart = FormBtnItineraire2.getCombo('depart');
								depart.loadXML("villeptions2.php?d="+value);
								arrivee = FormBtnItineraire2.getCombo('arrivee');
								arrivee.loadXML("villeptions2.php?a="+depart.getSelectedText());
								return true;
							}
							);
							FormBtnItineraire2.attachEvent("onButtonClick", function(name)
							{
								if(name=="enregistrer")
								{	
									gridtineraire.addRow((gridtineraire.getRowsNum()+1), [FormBtnItineraire2.getItemValue('modetransport'),FormBtnItineraire2.getItemValue('depart'), FormBtnItineraire2.getItemValue('arrivee')]);	
									modalItineraire2.close();										
								}
								//modalItineraire2.close();																																												
							}
							);
						  }

the line problem is this:

depart = FormBtnItineraire2.getCombo('depart');
								depart.loadXML("villeptions2.php?d="+value);
								arrivee = FormBtnItineraire2.getCombo('arrivee');
								arrivee.loadXML("villeptions2.php?a="+depart.getSelectedText());

Thank you for your willingness to help me

I forgot to tell you that the following error is appears:

TypeError: FormBtnItineraire2.getCombo is not a function	
depart = FormBtnItineraire2.getCombo('depart');

You need to get combo in aftercall:

depart.loadXML("villeptions2.php?d="+value, sunction(){ arrivee = FormBtnItineraire2.getCombo('arrivee'); arrivee.loadXML("villeptions2.php?a="+depart.getSelectedText()); });

thank you for your tireless support
I proceeded as follows:

depart = FormBtnMission.getCombo('depart');
								depart.loadXML("villeptions2.php?d="+value, sunction(){
								arrivee = FormBtnItineraire2.getCombo('arrivee');
								arrivee.loadXML("villeptions2.php?a="+depart.getSelectedText());
							});

but I have the following error

SyntaxError: missing ) after argument list
depart.loadXML("villeptions2.php?d="+value, sunction(){

Oh, sorry…
I wrote thw world “function” with a mistake…
It seems like you have missed it too and it brought an error :slight_smile:

ah!
I corrected, but no change
I do this:

depart = FormBtnMission.getCombo('depart');
                                depart.loadXML("villeptions2.php?d="+value, function(){
                                arrivee = FormBtnItineraire2.getCombo('arrivee');
                               arrivee.loadXML("villeptions2.php?a="+depart.getSelectedText());
                               });

and the error is as follows:

TypeError: FormBtnMission.getCombo is not a function
	

depart = FormBtnMission.getCombo('depart');

Have you a combo name in your foem xml?
Here is working sample for you
cmb.rar (119 KB)

Thank you for the support,
But my problem is not to make a “combo”, I already do it well.
My problem is the following:
I want to make three “combo”, wherein:
second options are sorted according to the option chosen on the first “combo” and
third options are sorted according to the option chosen on the second “combo”.
I send you the full file of what I want to do.

Regards

Hello, I briefly describe my problem;

I have three form of “select” type,and I want that the elements of the second “select” is sorted according to the value chosing in first “select” . in the same way, the elements of the third “select” is sorted according to the value chosing in second “select” .
All this by using the event “Onchange”.

I’ve done everything, but to no avail.

Thank you for helping.
form.rar (73.9 KB)

Can suggest you the next example:

[code]formData1 = [{
name: “input1”,
id: “input1”,
type: “input”,
label: “Item’s label”,
position: “label-top”,
value: “”
}, {
type: “button”,
name: “saveF1”,
command: “save1”,
value: ‘Save’
}];

        formData2 = [{
            type: "combo",
            id: "combo1",
            width: 200,
            name: "combo1",
            label: "Select name",
            position: "label-top",
            connector: "../___xml/combo_2.xml"
        }, {
            type: "button",
            name: "saveF2",
            command: "save2",
            value: 'Save'
        }];

        formData3 = [{
            id: "combo2",
            type: "combo",
            width: 100,
            name: "combo2",
            label: "Select parent",
            position: "label-top",
            connector: "../___xml/combo_0.xml"
        }, {
            type: "newcolumn",
            offset: "20"
        }, {
            id: "combo3",
            type: "combo",
            width: 100,
            name: "combo3",
            label: "Select child",
            position: "label-top"
            //hide: true
        }];

        form3 = new dhtmlXForm("parentId", formData3);
        form3.attachEvent("onChange", function(combo, value, is_checked) {
            if (combo !== 'combo2') {
                return true;
            }
            combo3 = this.getCombo('combo3');
            if (value == "Parent 1")
                combo3.loadXML("../___xml/combo_0_1.xml");
            else if (value == "Parent 2")
                combo3.loadXML("../___xml/combo_0_2.xml");
            return true;
        });
        form3.attachEvent("onButtonClick", function(saveF3){
            var textPar = form3.getItemValue('combo2');
            var textChi = form3.getItemValue('combo3');
            var selected = tree.getSelectedItemId();
            tree.setItemText(selected, textPar + '_' + textChi);
        });[/code]

You can use xml formdata too.

this is the result:
form.rar (74.3 KB)

You forget include combo xml connector for “Select child” combo. You need one more nested level.

so far it does not work, I’ll try with JQuery.

thank you for the support.

You are welcome!