Copy link to clipboard
Copied
Hi experts,
Need to display Multiple textfield by select one choice from combobox, how can I do that?
The textfields are ready texts and hidden, just appear when select something from combobox, one textfield has many data in the name: txt1, txt2, txt3, ...
The image will explain idea:
Thanx in advanced
Copy link to clipboard
Copied
You din't have to make different textfields appear. You can use the same ones and dynamically write the data into them when a selection is made.
You could create an array (or arrays) that hold the data in the same indexing as the combobox, so that when a selection is made you can used the selectedIndex property of the combobox the extract the data from the array(s).
Copy link to clipboard
Copied
Thank you for answer Mr. Ned Murphy
But I need 3 textfields because everyone has a different data and I want to connect it all with one choice of combobox
Could you write it as codes please sir?
Copy link to clipboard
Copied
Yes, you need three textfields, but not more than that. I will not be writing your code for you. GIve it a try and if you can't get it working, post the code that isn't working. You should research the ComboBox component in the help documentation if you have no familiarity with using it.
Copy link to clipboard
Copied
Since you said that, I tried many times, before this post, to put codes, create, copy...etc and also searched for long time but nothing work with me.
So I'll write my codes and ideas here:
I made dataprovider Array = [dp1,dp2,dp3...etc] in combobox based on selected items before it works fine, then I used this codes to create textfield that will display dependign on selected item in combobox
var txt1:TextField = new TextField();
var txt2:TextField = new TextField();
var txt3:TextField = new TextField();
var textfields:Array = [txt1,txt2,txt3];
txt1.text = "Toyota" + "\n";
txt1.appendText("Camry 2013\n");
txt1.appendText("Price: 22000$");
txt1.width = 577.95;
txt1.height = 342.20;
txt1.x = 31;
txt1.y = 495.90;
txt2.text = "Nissan\nAltima 2013\nPrice: 19000$");
txt2.width = 577.95;
txt2.height = 342.20;
txt2.x = 31;
txt2.y = 495.90;
txt3.text = "Honda\nAccord 2013\nPrice: 21000$");
txt3.width = 577.95;
txt3.height = 342.20;
txt3.x = 31;
txt3.y = 495.90;
combobox3.addEventListener(Event.CHANGE, changetext1);
combobox3.dataProvider = dp1;
function changetext1(e:Event):void{
switch(e.currentTarget.selectedItem.label){
case "Toyota car": txtarea1.textfields = txt1;break;
case "Nissan car": txtarea1.textfields = txt2;break;
default:break;
}
}
combobox3.addEventListener(Event.CHANGE, changetext2);
combobox3.dataProvider = dp2;
function changetext2(e:Event):void{
switch(e.currentTarget.selectedItem.label){
case "GMC car": txtarea1.textfields = txt4;break;
case "Ford car": txtarea1.textfields = txt5;break;
default:break;
}
}
any solutions sir?
Also this idea to display in one text area, how can I display in more than one text area with one choice?
Copy link to clipboard
Copied
Describe what you are trying to do in detail. What is the data that you are providing to the combobox? What should the result of choosing an item from the combobox be as far as the three textfields you show.
For the code you show you appear to be reassigning things to the same combobox where you probably only want to have one event handler function for when it changes.
Copy link to clipboard
Copied
I want to make database of car classification and later other things
combobox dataproviders: Array = [dp1,dp2,dp3...etc]
dp1: economic cars: A, B, C
dp2: medium cars: D,E,F
dp3 luxury cars: G,H,I
textfield will display details:
textarea1: Type & model
textarea2: price
trxtarea3: installment
this details will be displayed as text = txt1, txt2, txt3, txt4 ... etc.
e.g:
if combobox dp1 label = A then textarea1 = txt1, textarea2 = txt2, textarea3 = txt3
if combobox dp2 label = D then textarea1 = txt3, textarea2 = txt4, textarea3 = txt5
Find more inspiration, events, and resources on the new Adobe Community
Explore Now