I've looked around and from what I can tell, the code seems right. Basically crating a JS array and passing PHP values to it to use in an onChange to fill a text field.
The dropdown gets populated fine but the text field does not autopopulate onChange. I'm not too fluent with JS but have a good analytical mind and from what I can see, the logic seems right.
Here is the code...any help would be appreciated.
<?php
include('connectdb.php');
$CENTRE = $_SESSION['centreAFB'];
$qryFormList = mysql_query("SELECT * FROM tblLogin WHERE ACCT_TYPE = '2' AND loginCENTRE = '$CENTRE' ORDER BY loginNOM");
echo "<script type='text/javascript'> var formCourriel = new Array()";
while($resFormList = mysql_fetch_assoc($qryFormList))
{
echo "formCourriel[".$resFormList['loginID']."] = ".$resFormList['COURRIEL'].";";
}
mysql_close($database);
echo "
function changed(sender)
{
document.getElementById('AFB_FORM_COURRIEL').value = formCourriel[sender];
}
";
echo "</script>";
echo "<select name='AFBFORM' id='AFBFORM' onChange='changed(this.value)'>";
echo "<option selected disabled>Sélectionnez</option>";
mysql_data_seek($qryFormList,0);
while($resFormList = mysql_fetch_assoc($qryFormList))
{
echo '<option value="'.$resFormList['loginID'].'"';
if($_SESSION['FORMDATA']['AFBFORM'] == "".$resFormList['loginID']."")
{
echo 'selected';
}
else
{
echo ' ';
}
echo '>'.$resFormList['loginNOM'].'</option>';
}
echo "</select>";
?>