physaux Posted November 20, 2009 Share Posted November 20, 2009 Ok guys, I'm stuck at this little problem Everything up to reading in the data is fine, I am reading in my data in a function like this: <?php <form method="POST" action="index.php?id1=admin&id2=edit"> $returnvalue['content']=' User by Title: <select name="id" size="1"> '; $query = "SELECT * FROM db_name"; $result = mysql_query($query, $connection); if(!$result){ echo "FAIL"; } while($row = mysql_fetch_array($result)) { $returnvalue['content'].='<option value="'.$row["id"].'">'.$row["title"].'</option>'; } $returnvalue['content'].='</select><br> <input type="submit" value="Edit this member"> </p> ?> Now this is fine, and it works. But the list is crazy long! I want to have a "double dropdown", where the first dropdown would select the "class", and then the second dropdown would only show the names that have the same "class". My database has the following fields id- unique class- common title- unique How could I go about breating a double dropdown, where the second list depends on the first lists choice? Any help? Link to comment https://forums.phpfreaks.com/topic/182316-reading-a-sql-table-and-putting-it-into-a-double-select-dropbox-by-id-how/ Share on other sites More sharing options...
The14thGOD Posted November 20, 2009 Share Posted November 20, 2009 a few ways i can think of. 1. have a javascript on select fire an ajax request to pull in the next drop down 2. make it a step process, once the user selects the class they have to hit submit, the page reloads and has the 2nd drop down with only the options corresponding to the first drop down. 3. render out all of the 2nd drop down possibilities and display:none; on them. then on select have a javascript function display:block; on the corresponding drop down menu. Link to comment https://forums.phpfreaks.com/topic/182316-reading-a-sql-table-and-putting-it-into-a-double-select-dropbox-by-id-how/#findComment-962087 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.