4 Replies Latest reply on Apr 25, 2011 7:41 AM by dzelst

    Dynamic Form list/menu

    dzelst

      I'm trying to insert a dynamicly generated form list/menu dropdown item.

       

      Everything works but the list always shows me the last record from the database as the first item in the list (ASC or DESC).

      I want to put a dummy label as the first item in the list like: Select from list

      How can i do this, because even if i put a static value in the value list items, it still shows the last item from the recordset first instead of the static value.

       

      Does anybody have an idea how i can create a dynamic pulldown list in my form with the first item listed to be a statich dummy tekst or label like "Select from list etc"

       

      Thanks,

        • 1. Re: Dynamic Form list/menu
          Level 4

          For those that are not looking over your shoulder or reading your mind it helps if you provide your code.

          • 2. Re: Dynamic Form list/menu
            dzelst Level 1

            I created a normal recordset with Dreamweaver getting tea

            m_id and team_names out of the database. Then i list the teamnames in a form list/

            menu (dropdown) to show all the available teams. Again it shows me the last record from the

            recordset as the first list item and i want a standard "select this" text or something default.

             

            The form code below is generated by dreamweaver itself. I already tried to also put one static value in the value list property but i get the same result. To me it looks like the while loop is overriding whatever you put as static text.

             

            <form id="form1" name="form1" method="post" action="">
              <label for="list_teams">Teams:</label>
              <select name="list_teams" id="list_teams">
                <?php
            do { 
            ?>
                <option value="<?php echo $row_Teams['team_id']?>"<?php if (!(strcmp($row_Teams['team_id'], $row_Teams['team_id']))) {echo "selected=\"selected\"";} ?>><?php echo $row_Teams['team_name']?></option>
                <?php
            } while ($row_Teams = mysql_fetch_assoc($Teams));
              $rows = mysql_num_rows($Teams);
              if($rows > 0) {
                  mysql_data_seek($Teams, 0);
               $row_Teams = mysql_fetch_assoc($Teams);
              }
            ?>
              </select>
            </form>

            • 3. Re: Dynamic Form list/menu
              Level 4

              <form id="form1" name="form1" method="post" action="">
                <label for="list_teams">Teams:</label>
                <select name="list_teams" id="list_teams">

                <option value="" selected="selected">Select This</option>
                  <?php
              do { 
              ?>
                  <option value="<?php echo $row_Teams['team_id']?>"><?php echo $row_Teams['team_name']?></option>
                  <?php
              } while ($row_Teams = mysql_fetch_assoc($Teams));
                $rows = mysql_num_rows($Teams);
                if($rows > 0) {
                    mysql_data_seek($Teams, 0);
                 $row_Teams = mysql_fetch_assoc($Teams);
                }
              ?>
                </select>
              </form>

              • 4. Re: Dynamic Form list/menu
                dzelst Level 1

                Thanks!!  Looks like i used

                one field to many in the dynamic property window. It works now.