hi can u help me to pass php values to javascript array,
actually I have many drop down boxes
I need onchange of one of them to change the values of the others according to the value of the first one
and since I dont need to submit the form to take the values and use them in php , I tried at the first of my program to put all the data in javascript arrays and then onchange I use javascript function to search for my values. this is a logical solution but it is not working with me, can u find the problem
this is my program:
search.php
<?php
$db = mysql_connect('localhost','root', 'memo1982');
mysql_select_db ("collab1",$db);
$sql=mysql_query("select from student",$db);
?>
<script language='javascript'>
function lolo()
{
p=0;
var id=new array();
var fname=new array();
var lname=new array();
var gender=new array();
var level=new array();
var type=new array();
<?
$sql1=mysql_query("select from sanction s, student st, officer o where s.Id=st.Id and s.Oid=o.Oid",$db);
while($row = mysql_fetch_array($sql1, MYSQL_NUM))
{?>
id[p]=<?=$row["Id"]?>;
p=p+1;
<?
}?>
document.write(p); //i made this one only to see if the function is working but it is not working
}
</script>
<html>
<head>
<title>Disciplinary Sanctions Search</title>
<img src='ltu.bmp' width="974" height="72"/>
<Style TYPE="text/css">
.boldtable, .boldtable TD, .boldtable TH
{
font-size:12pt;
color:#000066;
}
</style>
</head>
<body background='bg.jpg'>
<h1><font color="#000080">Search<hr></font></h1>
<form name='search' method='post' action='search2.php'>
<table class='boldtable'>
<tr>
<td bgcolor='99cccc'>Student ID:</td>
<td>
<select name='sid' class='boldtable' onchange="lolo()">
<option value='All'>All
<?while ($row = mysql_fetch_array($sql, MYSQL_NUM)) {?>
<option value='<?= $row[0]?>'><?= $row[0]?>
<?
}?>
</select>
</td>
</tr>
<tr>
<td bgcolor='99cccc'>First Name:</td>
<td>
<select name='fn' class='boldtable'>
<option value='All'>All
<?
$sql=mysql_query("select * from student",$db);
while ($row = mysql_fetch_array($sql, MYSQL_NUM)) {?>
<option value='<?= $row[1]?>'><?= $row[1]?>
<?
}?>
</select>
</td>
</tr>
<tr>
<td bgcolor='99cccc'>Last Name:</td>
<td>
<select name='ln' class='boldtable'>
<option value='All'>All
<?
$sql=mysql_query("select * from student",$db);
while ($row = mysql_fetch_array($sql,MYSQL_NUM)) {?>
<option value='<?= $row[2]?>'><?= $row[2]?>
<?
}?>
</select>
</td>
</tr>
<tr>
<td bgcolor='99cccc'>Gender:</td>
<td>
<select name='sex' size='3' class='boldtable'>
<option value='All' selected>All
<option value='M'>Male
<option value='F'>Female
</select>
</td>
</tr>
<tr>
<td bgcolor='99cccc'>Level:</td>
<td>
<select name='level' size='6' class='boldtable'>
<option value='All' selected>All
<option value='G'>G-Grad
<option value='Sr'>Sr-Senior
<option value='J'>J-Junior
<option value='S'>S-Soph
<option value='F'>F-Fresh
</select>
</td>
</tr>
<tr>
<td bgcolor='99cccc'>Date From:</td>
<td>
Month:<select name='monthf' class='boldtable'>
<option value='0'>
<?
for ($i=1;$i<=12;$i++) {?>
<option value='<?= $i?>'><?= $i?>
<?
}?>
</select>
Day:<select name='dayf' class='boldtable'>
<option value='0'>
<?
for ($i=1;$i<=31;$i++) {?>
<option value='<?= $i?>'><?= $i?>
<?
}?>
</select>
Year:<select name='yearf' class='boldtable'>
<option value='0'>
<?
for ($i=1990;$i<=2010;$i++) {?>
<option value='<?= $i?>'><?= $i?>
<?
}?>
</select>
</td>
</tr>
<tr>
<td bgcolor='99cccc'>Date To:</td>
<td>
Month:<select name='monthto' class='boldtable'>
<option value='0'>
<?
for ($i=1;$i<=12;$i++) {?>
<option value='<?= $i?>'><?= $i?>
<?
}?>
</select>
Day:<select name='dayto' class='boldtable'>
<option value='0'>
<?
for ($i=1;$i<=31;$i++) {?>
<option value='<?= $i?>'><?= $i?>
<?
}?>
</select>
Year:<select name='yearto' class='boldtable'>
<option value='0'>
<?
for ($i=1990;$i<=2010;$i++) {?>
<option value='<?= $i?>'><?= $i?>
<?
}?>
</select>
</td>
</tr>
<tr>
<td bgcolor='99cccc'>Student Conduct Officer:</td>
<td>
<select name='officer' class='boldtable'>
<option value='All'>All
<?
$sql1=mysql_query("select * from officer",$db);
while ($row = mysql_fetch_array($sql1, MYSQL_NUM)) {?>
<option value='<?= $row[0]?>'><?= $row[1]." ".$row[2]?>
<?
}?>
<tr>
<td bgcolor='99cccc'>Violation Type:</td>
<td>
<select name='type' class='boldtable'>
<option value='All' selected>All
<option value='DW'>DW-Warning
<option value='DP'>DP-Probation
<option value='LP'>LP-Loss Privileges
<option value='LAC'>LAC-Loss Acad Credit
<option value='F'>F-Fines
<option value='RES'>RES-Restitution
<option value='DS'>DS-Sanction
<option value='US'>US-Univ. Suspend
<option value='UE'>UE-Univ. Expel
<option value='IS'>IS-Interim Suspend
<option value='ISH'>ISH-Interim Suspend Housing
<option value='TR'>TR-Temp Reassign
<option value='TRP'>TRP-Temp Restrict-Personic Contact
<option value='WDP'>WDP-Withdraw Prior to Disposition
</select>
</td>
</tr>
<tr>
<td bgcolor='99cccc'>Section:</td>
<td>
<input type='text' name='section'/>
</td>
</tr>
</table>
<br>
<input type='hidden' name='page' value='search1'/>
<input type="submit" value="Search"/>
<input type="reset" value="Reset"/>
</body>
</html>