8 Replies Latest reply on Nov 24, 2008 1:17 AM by (Juergen_Helmers)

    default values for dependent drop down menu


      I did create an insert record page that lets the user put in information using text fields. In addition the form has a dependent drop down menu for a category and then depending on the chosen category, the user is presented with choices in a second drop down menu for subcategories.

      The insert of the record itself works fine.

      The records are then listed in a table. A link to a details page should then list all fields of a chosen record. I have another form sporting them dependent drop down menus again. Since I retrieve a record from the database I would like to have the drop down menus default to the values stored in the database.

      But whatever I tried the menus always default to the respective first entries in each menu.

      I tried to use the "select value equal to" field in the "insert record" for the category and the "Default detail value" field in the dependent drop down item for the subcategory field.

      Any pointers anybody?

      Thanks in advance
        • 1. Re: default values for dependent drop down menu
          mrcharis2003@yahoo.c Level 1
          Hi there I cannot understand your request fully but I think I understand....

          I think I have done nearly exactly what you need

          I will try to explain

          for a start I am working on a art gallery site that has many different artists and many different paintings

          I am able to add a new artist and have that artist name appear automatically in a dropdown menu on my add painting form page so that when I add a new painting I do not have to type the arrtists name every time

          I am not sure this is what you need but I think maybe....

          (i have another site that displays different categories of jewellry... with a form that has same dropdown and can choose product category.... but the process is the same)

          the way I did it was to first create an 'artist_info' table in my database and an 'add artist page' pretty simple

          Then an painting_pnt table in my database and an 'add painting' page with a form that contains a dropdown menu that is dynamically populated from the artist_infotable... label from the artist_name field value from the artist_id field so the form uses two recordsets.......

          Then in my painting_pnt table I have a field that stores the artist_id

          So when I add a new artist..... the name automatically appears in the dropdown menu when I add a new painting I choose the artist name and then later I can filter recordsets on my detail pages using the id_artist....

          there is a lot more to it as well but that should get you started

          I hope this helps

          If you have any questions at all I will try to explain better

          • 2. Re: default values for dependent drop down menu
            mrcharis2003@yahoo.c Level 1
            Oh and i did get the same thing working with a Dependant dropdown

            will go into detail more if you need

            I still not sure exactly what you need

            have a nice day
            • 3. Re: default values for dependent drop down menu
              Level 1

              thanks for the attempt to help but that is not what I meant. Let me try to explain it better (hopefully, :-) )

              If I have a record in a database and I create a page to update that record using the update record wizard, I call that page with a URL parameter, usually like so:


              the 34 is the id of the record I want to update here. Ok. If I have a field whose entry can be chosen from a menu (I usually have dynamic menus, the entries fed from a db table) the field in the update page can be the same menu and I can pass the field value from the record I would like to update along and have the field default to the entry from the db record. But if I have a dependent drop down menu, I seem to fail to assign the field value to the menu and its dependent menu they always default to the first values in the list of each menu items.

              I hope this makes it any more clear...

              Cheers Juergen
              • 4. Re: default values for dependent drop down menu
                Waleed Barakat Level 1
                Hi Helmers
                Please read this tutorial to learn how to build dynamic dropdown menues with dreamweaver and addt, also it guide you to learn how to make a relation between a number of tables together by using the dependent dropdown menu server behavior.

                • 5. Re: default values for dependent drop down menu
                  I am also facing the same problem. Waleed, does your tutorial cover this. I don't think so. I need to pass the value from the dependent drop down menus to a different table (along with some other field values, which the user will enter manually). Any thoughts!!
                  • 6. Re: default values for dependent drop down menu
                    Level 1
                    Hi Jayceedxb,

                    I actually solved this. My mistake was that the dependent drop down does not store the label but the ids of the two menus in the database. The default can be assigned during the setup of the dependent drop down menu (for the dependent menu) and can directly be assigned to the master menu by clicking on it and then set the value in the properties section.

                    So you will need to translate the id into a label value you would like to present to the user using an INNER JOIN for the query, e.g.:

                    SELECT a.date,b.cat_label AS category,a.product FROM stuff AS a
                    INNER JOIN categories AS b ON a.cat=b.id_cat
                    WHERE ....
                    ORDER BY ...

                    This will pull the label from the categories table (defined as b) and translate the value using the stored id in stuff (defined as a) to the appropriate label.

                    Cheers Juergen
                    • 7. Re: default values for dependent drop down menu
                      Level 1
                      Thanks Juergen,
                      Since days, I couldn't get it working. Now there is a light at the end of the tunnel, and that's in your message.

                      My question is where do I INNER JOIN? means, while retrieving the records for the categories or while posting it. Obviously SELECT is for selecting not for INSERTing. Here my problem is that I want to post the labels to the database. What it is currently passing is the keys. I am getting lost somewhere.

                      Thanks for any help
                      • 8. Re: default values for dependent drop down menu
                        Level 1
                        Hi Jay

                        the inner join is when you retrieve record from the database. Let's say you have an address book and a table of, I don't know, assigned rooms where people work. the address book identifies people by id, e.g. id_user:
                        id, id_user, name, lastname, phone, fax, ...

                        So the second table looks like this:
                        id, id_user, building, floor, room

                        So the tabels can be connected by id_user which is the same for every user. If you wpuld like to design a query resulting in the name and room for all users, you would use an inner join to coonect the tables with each other:

                        SELECT a.name, a.lastname, b.room FROM address AS a
                        INNER JOIN location as B ON a.id_user=b.id_user

                        So if you would like to put something in the database, you will need to perform an insert into two tables:

                        INSERT INTO address (name,lastname,phone,fax,id_user) VALUES(John,Doe,123456,54321,9999);
                        INSERT INTO location (id_user, building, floor, room) VALUES(9999,'some bulding',2,2.056)

                        Just make sure you use the same id_user which you will have to either generate, or get the last e.g. max value from the database before hand and increase it by one and then use this value for your two inserts...

                        Cheers Juergen