5 Replies Latest reply on May 12, 2009 5:33 PM by zzipper7

    Editable Drop-Down List




      I am using Dreamweaver's Editable Drop-Down List

      Application panel, Server Behaviors > + > Developer Toolbox > Form Controls > Editable Drop-down


      Which has been a GREAT option, but I need to add on 1 option, when I am about to ADD an item to the list, all you can do is add 1 item to 1 column in a database.


      Database Struture:

      listid   userid   listItem    listitemValue


      But all I can get it to update is listItem I need to be able to when the button, "ADD THIS" is pushed, that I can add a value to USERID also, is this possible? I tried diving deap into it, but some certains things I just didn't understand that far down.


      Any help would be greatly appreciated!



      Cheers, and thank you in advance.


        • 1. Re: Editable Drop-Down List
          zzipper7 Level 1

          If I'm following you on this, there are two solutions:


          Deside where your id will come from, a recorset, a  session, or a "entered value" (a fixed value)


          The first is the most typical,  your insert statement needs a value assigned to it:

          • so there needs to be a hidden feild in your form that echoes the id from the record set,
          • or...
          • an entered value (your own value) in the insert statement

          both can be done through the wizard or under the server behaviors tab by clicking on "insert record, than "feilds tab"


          The second is you can edit your code directly:


          Both types of insert statements have very easy to spot code lines that can be edited easily - take a look

          1. If you are using ADDT its :  $ins_contacts->addColumn("userid", "STRING_TYPE", "POST", "myform_id");   ..but use your form names.
          2. If you are using DW its :     GetSQLValueString($_POST['myform_id'], "text"),

          Both you can replace the form value with an "entered value" Ex: GetSQLValueString('my string of text', "text"),


          Basicly the short of it is, that you need to tell the insert record, through the wizard or the code, where the data is coming from (form or string)  and where is the data going ( what table, what column)...the table part is already handled... so the code above says what column.


          I hope I understood your delima, sorry in advance if I missed it completely.


          Good luck.

          • 2. Re: Editable Drop-Down List
            justingiesbrecht Level 1

            Thanks for your detailed reply, there are a couple things that don't apply.


            When creating an editable drop-down, the steps are.

            1. Create a recordset so it shows all the items in the drop down list.

            2. Create the editablility through the form it supplies.

                      Here we only have a few options.

                      - The defined recordset

                      - Get Labels

                      - Get Values

                      - Show Add Button

                      - Default Value...


            Those are the items only of value. So basically I believe what I need in short is, When somone clicks the ADD NEW button, it needs to be able to apply that hidden valueid


            So once you do that, there is only the INSERT transaction for the entire form, not for the specific drop-down list "ADD" feature.



            Sorry I didn't explain better before, I hope this helps.





            • 3. Re: Editable Drop-Down List
              zzipper7 Level 1

              Ok I completely misunderstood. Sorry for the confusion. I'm afraid I may not be much help on this particular function. Some functions I've really torn apart and modified, this is not one of them.


              This does not look like one of the more simple functions to change unlike some others,


              Before trying to go into lengthy info on how to break it down, is there any chance the info you are trying to update is some type of default name or incremental name, something than can be hard coded? ..or is it unique like a visitor, so you are pulling down each time? Ex:  User1, user2    vs.   sally101, david2009, etc.


              IF not, there are a several lines of variable setting and function modification to change at first glance.


              I can look into later, but the variables are not even in the same insert function page.


              Here is the Key line in WDG_recordsetInsert.php,


              $sql = 'INSERT INTO ' . $vars['table'] . ' (' . KT_escapeFieldName($vars['updatefield']) . ') VALUES (' . KT_escapeForSql($text, 'STRING_TYPE') . ')';


              but the vars appear to come out of an array in  'WDG_functions.inc.php : here is the function variables being set for the insert function above


              $WDG_sessInsTest = &$_SESSION['WDG_sessInsTest'];

                   $WDG_sessInsTest[] = array(

                        'conn' => $connectionName,

                        'rsName' => $rsName,

                        'table' => $sqlTable,

                        'idfield' => $idField,

                        'updatefield' => $updateField     );


              This array (at first glance) could be modified, but I can't promise that the vars will carry through because I don't see exactly where this array is being used again.


              As I mentioned, if the values you need are something you could hard code and increment, you could easily modify the 'insert to' function above.


              I would also toy around with some $_POST data and Session data vars and see if you can drop those straight into the sql statement above.


              Sorry I can't be more help on this one.

              • 4. Re: Editable Drop-Down List
                justingiesbrecht Level 1

                Hey Thanks, you know I didn't think about actually modifying the actual SQL query, I didn't clue in at 2am last night. But it worked out, used some $_SESSION variables and was able to jimmy it to work.


                Thanks for the direction mate!




                • 5. Re: Editable Drop-Down List
                  zzipper7 Level 1

                  That’s great...thanks for the update. I have found that a lot of times its easier to go around the functions than to modify every single one. You have to pick your battles but ADDT does have great toys when you need good stuff on the fly.