Connecting Tech Pros Worldwide Forums | Help | Site Map

dynamic dropdowm list

Newbie
 
Join Date: Feb 2007
Posts: 4
#1: Feb 27 '07
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

Lives Here
 
Join Date: Sep 2006
Posts: 12,070
#2: Feb 27 '07

re: dynamic dropdowm list


Quote:

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 ...
Member
 
Join Date: Jan 2007
Posts: 32
#3: Feb 27 '07

re: dynamic dropdowm list


Quote:

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=fasfd dbanme=gfd user=fda");
$myresult= pg_exec($connection, "select field_name from table_name");
for ($lt=0, $lt<pg_numrows($myresult); $lt++){
$var=pg_result($myresult, $lt, column_name);

echo "<option>$var<option>";
}[/PHP]
Lives Here
 
Join Date: Sep 2006
Posts: 12,070
#4: Feb 27 '07

re: dynamic dropdowm list


Quote:

Originally Posted by anuragpj

You can try this after connecting to the database
[HTML]<input name="select">[/HTML]
[PHP]$connection=pg_connect("host=fasfd dbanme=gfd user=fda");
$myresult= pg_exec($connection, "select field_name from table_name");
for ($lt=0, $lt<pg_numrows($myresult); $lt++){
$var=pg_result($myresult, $lt, column_name);

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


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

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