Hi,
i am trying to populate three JS arrays using PHP and then display the items of one of them into a drop down list.
i am following a script that i found on the web, but while it appears that i have created three js arrays the drop down menu remains empty.
Could u please tell me what goes wrong?
<?php
$fields = array();
$fields['patientID']=array();
$fields['patient_type']=array();
$fields['patient_status']=array();
...
$result = mysql_query("SELECT patientID, patient_type, patient_status FROM PATIENT") or die ("Could Not execute Query");
while($row = mysql_fetch_array($result)){
array_push($fields['patientID'],$row['patientID']);
array_push($fields['patient_type'],$row['patient_type']);
array_push($fields['patient_status'],$row['patient_status']);
}
?>
<script language="JavaScript">
var js_patientID = new Array();
var js_patienttype = new Array();
var js_patientstatus = new Array();
<?
for ($i=0; $i<count($fields['patientID']); $i++) {
echo 'js_patientID['.$i.']= "'. $fields['patientID'][$i] .'";';
}
for ($i=0; $i<count($fields['patient_type']); $i++) {
echo 'js_patienttype ['.$i.']= "'. $fields['patient_type '][$i] .'";';
}
for ($i=0; $i<count($fields['patient_status']); $i++) {
echo 'js_patientstatus['.$i.']= "'. $fields['patient_status'][$i] .'";';
}
?>
</script>
<select name="patient" size="1">
<script type="text/javascript">
for(i = 0; i < js_patientID.length; i++){
document.write("<option>" + js_patientID + "</option>");
}
</script></select>
I would very much appreciate any help.
Thanks.