CincoPistolero Posted December 6, 2006 Share Posted December 6, 2006 I need to create a form that when I select an option in a dropdown box, it takes the id from that item and uses that id to fill another drop down boxes selections. Getting the initial dropdown info with ID is easy, but I'm not sure how to get the other box to populate.Below is my code for the drop downs. The first box is populating the correct data, but when something is selected, no matter what it is, the second box always shows the same thing.Ideally, I'd like the second box either to not show up initially, or have it empty until something is chosen in the first dropdown.[code]<?php /* Size Information Query */$querysize = " SELECT * FROM size where drumID=1 ORDER BY `sizeID` ASC LIMIT 0 , 30 ";$resultsize = mysql_query($querysize) or die ("Error in query: $querysize. " . mysql_error());?> <select name='size' onChange="if (document.myform.size.selectedIndex != 0) window.open(url = document.myform.size.options[document.myform.size.selectedIndex].value,'_self'); else alert('Please choose from menu.')"> <option selected>Select Size</option><?php while ( $rowsize= mysql_fetch_array($resultsize)){extract($rowsize); echo " <option value='rhino_new.index.php?sizeID=$sizeID'>$sizeName</option>" ;}?> </select> </td> <td width="11%"><b><u><font face="Verdana" color="#ff9c31" size="2">FINISH: </font></u></b></td> <td width="24%"> <?php if ($sizeID >0) { ?> <?php /* Finish Information Query */ $queryfinish = " SELECT * FROM finish where sizeID='$sizeID' ORDER BY 'finishID' ASC LIMIT 0, 30 "; $resultfinish = mysql_query($queryfinish) or die ("Error in query: $queryfinish. " . mysql_error()); ?> <select name='finish' onChange="if (document.myform.finish.selectedIndex != 0) window.open(url = document.myform.finish.options[document.myform.finish.selectedIndex].value,'_self'); else alert('Please choose from menu.')"> <option selected>Select Finish</option><?php while ( $rowfinish= mysql_fetch_array($resultfinish)){extract($rowfinish); echo " <option value='rhino_new.index.php?sizeID=$sizeID?finishID=$finishID'>$finishName - $price</option>" ;}?> </select> <?php } else { ?> <?php } ?>[/code] Link to comment https://forums.phpfreaks.com/topic/29739-dynamic-drop-down-boxes/ Share on other sites More sharing options...
drifter Posted December 7, 2006 Share Posted December 7, 2006 I believe you are looking for some javascipt not php Link to comment https://forums.phpfreaks.com/topic/29739-dynamic-drop-down-boxes/#findComment-136592 Share on other sites More sharing options...
papaface Posted December 7, 2006 Share Posted December 7, 2006 Yeah. Always remember PHP is SERVER-side. Therefore nothing in the browser is done by php.You need a client-side scripting language i believe such as Javascript. Link to comment https://forums.phpfreaks.com/topic/29739-dynamic-drop-down-boxes/#findComment-136596 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.