Click to See Complete Forum and Search --> : menus and List


winstond
12-13-2006, 04:47 PM
Hi ev'ry one I need your help!... if you can bring it I'll aprecciate!

Ok, here's is my problem

I got iin my site two list.. one of them I show the possible options that you have to select, and my code goes like this:

<td>Center</td>
<td><select name="idCentro"><?
mysql_connect("server","name_user","password");
mysql_select_db("nameofDB");
$qr = mysql_query("SELECT idCentro, nomCentro FROM centro");
$nrows = mysql_num_rows($qr);
if ($nrows == 0) {
?>
<option value="0" selected>There's not a center registered</option>
<?
} else {
for ($j=0; $j<$nrows; $j++) {
$row = mysql_fetch_array ($qr);
$idCentro = $row ['idCentro'];
$nomCentro = $row ['nomCentro'];
?>
<option value="<? echo $idCentro; ?>" <? if ($j ==0) { echo "selected"; } ?>><? echo $nomCentro; ?></option>
<? } } ?>
</select></td>, below this list I want to show in the same page another list but with the labs that belongs to a determinated center ( I guess I'll take it with the $idCentro;) I know I need a javascript code, but I don't know how it works, or simply codify it..

I hope you understand my shy xplanation!

I'll wait your answers!

God bless all!

Winston

bogu
12-14-2006, 04:18 AM
If u know this is a javascript question, then u should know that this is the thread for this question: ClientSide Technologies (http://phpbuilder.com/board/forumdisplay.php?f=27)

Is to much to explain, to many methods and the code is not an easy one, u should try searching for list-box communication. One of the method I like is using ajax, but u could do it with javascript arrays, or the simplest way to do but this is not so good u could submit your form after u select the first list-box and extract the value for your second list-box, but this will refresh your page ...

winstond
12-14-2006, 09:16 AM
Thanx!... I think I'll submit my form and it'll refresh my second one combobox

Thanx for oyur help... but if anybody knows a code or something like that than can copy, I'll appreciate!