4 Replies Latest reply on Jun 25, 2010 7:21 AM by djh88ukwb

    DropDownList being fed from AMFPHP array, outputing a differnet value - help ?

    djh88ukwb Level 1

      Hello all.

       


      I am using the following DropDownMenu

                  <s:DropDownList x="10" y="105" width="236" id="createCompanyInput" dataProvider="{linkedArr}" labelField="companyname" prompt="&lt;-- Select Company --&gt;"></s:DropDownList>

       

      I am pulling the data for the menu, from a MYSQL database, using AMFPHP.

       

      The database has a couple of fields.

       

      ref - companyname - firstname - email

       

      I am then trying to save some data to a mysql database, using the DropDownList as part of the user inputs.

       

      The code i am using to insert into the database is as

       

                  private function createNewJob():void
                  {
                      newcreateJobRefInput = createJobRefInput.text;
                      newcreateCompanyInput = createCompanyInput.value;
                      newcreatePositionInput = createPositionInput.text;
                      createJobRefInput.text = "";
                      createCompanyInput.text = "";
                      createPositionInput.text = "";
                      createNewJobService.send();   
                  }

       

      This works fine, puts the relevant fields into the mysql table.

       

      But what i would like to do, is instead of inserting the companyname selected from the dropdown list, but insert the relevant company ref into the table instead.

       

      How can i achieve this ?

       

      Thanks for the help

        • 1. Re: DropDownList being fed from AMFPHP array, outputing a differnet value - help ?
          Francisc Level 3

          Hello!

           

          I am not sure I understood exactly what you mean, but if you want to use the ref you can do this:

           

          newcreateCompanyInput = createCompanyInput.ref;

          • 2. Re: DropDownList being fed from AMFPHP array, outputing a differnet value - help ?
            djh88ukwb Level 1

            Hello,

             

            I will try to explain in more detail

             

            I have a form made in flex.  Three fields, "Ref Number" "Company Name" "Position".  Ref number and Position are text fields, while Company Name is a drop down combo box, with the data being fed in via mysql, using AMFPHP into an array.

             

            Now, the mysql table has a couple of columns, one being Company Name, which is what is being displayed in the form combo box, another field is ref, which is a unique ID.

             

            Now what i want to be able to do, is insert the data provided from the form, into a new table.

             

            So i was using the code

             

                        private function createNewJob():void
                        {
                            newcreateJobRefInput = createJobRefInput.text;
                            newcreateCompanyInput = createCompanyInput.labelField;
                            newcreatePositionInput = createPositionInput.text;
                            createJobRefInput.text = "";
                            createCompanyInput.labelField = "";
                            createPositionInput.text = "";
                            createNewJobService.send();   
                        }

             

            But i dont want the companyname stored in the table, i want the reference number, so i need to be able to change them, but i cant seem to do it.

             

            ANy suggestions?

            • 3. Re: DropDownList being fed from AMFPHP array, outputing a differnet value - help ?
              VRPDeveloper Level 3

              This is what I understood from your explanation. You have combobox for company Name and you do not want to add company name in new table but reference of selected company name . so here is the solution

               

              Create arraycollection from data you are geeting from database for comapany combobox

              CompanyArray=new ArrayCollection(
                              [{label:"companyname1", referenceID:"1"},
                              {label:"companyname2", referenceID:"2"},
                              {label:"companyname3", referenceID:"3"}])

              <mx:ComboBox id="myComboBox" dataProvider="{CompanyArray}"/>

              Now when you select companyname from combobox, you can also fetch referenceid along with companyname by using
              data.refernceID. Now you can use this ID and place into new table

              Hope you got this solution!!!