dynamic dropdowm list

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dangutm
    New Member
    • Feb 2007
    • 4

    #1

    dynamic dropdowm list

    how can i get data from a database into my dropdown list in a html form and
    and if i select from the first dropdown list the second dropdown load from the database the crosponding value of the first one dropdown
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    Originally posted by dangutm
    how can i get data from a database into my dropdown list in a html form and
    and if i select from the first dropdown list the second dropdown load from the database the crosponding value of the first one dropdown
    You could try loading the data into hidden selects and then use Javascript to play around with the autopopulating ...

    Comment

    • anuragpj
      New Member
      • Jan 2007
      • 32

      #3
      Originally posted by r035198x
      You could try loading the data into hidden selects and then use Javascript to play around with the autopopulating ...
      You can try this after connecting to the database
      [HTML]<input name="select">[/HTML]
      [PHP]$connection=pg_ connect("host=f asfd dbanme=gfd user=fda");
      $myresult= pg_exec($connec tion, "select field_name from table_name");
      for ($lt=0, $lt<pg_numrows( $myresult); $lt++){
      $var=pg_result( $myresult, $lt, column_name);

      echo "<option>$var<o ption>";
      }[/PHP]

      Comment

      • r035198x
        MVP
        • Sep 2006
        • 13225

        #4
        Originally posted by anuragpj
        You can try this after connecting to the database
        [HTML]<input name="select">[/HTML]
        [PHP]$connection=pg_ connect("host=f asfd dbanme=gfd user=fda");
        $myresult= pg_exec($connec tion, "select field_name from table_name");
        for ($lt=0, $lt<pg_numrows( $myresult); $lt++){
        $var=pg_result( $myresult, $lt, column_name);

        echo "<option>$var<o ption>";
        }[/PHP]

        Perhaps you'd then have
        [HTML]<select name="myValues" onChange="autop opulate()">[/HTML]

        Then have the js function populating another dropdown with values that depend on the currently selected values from the database

        Comment

        Working...