Hello
I have found the following script php/java for dynamic menu lists. Where a
selection from the first updates (filters items in) the other. I have
modified it for my tables.
However I am getting an error
Parse error: parse error, unexpected T_VAR in
e:\domains\i\id dsoftware.co.uk \user\htdocs\Qu estionDB\Questi ons.php on line
42
line 42 being
var mainselect = document.FormNa me.MainCategory ;
Im fairly new to php and dont use Java upto now. Can anyone see where I ve
gone wrong
<?php
session_start() ;
include("../include/connection.php" );
include("../Secure/login.php");
$Heading= 'QUESTION SELECTOR';
$Menu='<a href="../Secure/logout.php">Log out</a><br>';
include 'HeadQuest.php' ;
$Query = "SELECT SubjectNo, SubjectDesc, StatusID FROM Subjects WHERE
StatusID = 1 ORDER BY SubjectDesc ASC";
$Result = mysql_query( $Query, $conn );
?>
<HTML>
<HEAD>
<SCRIPT language="JavaS cript">
function BodyLoad()
{
var select = document.FormNa me.MainCategory ;
select.options[0] = new Option("Choose One");
select.options[0].value = 0;
<?PHP
$ctr = 1;
While( $Row = mysql_fetch_arr ay($Result) ) {
echo "select.opt ions[".$ctr."] = new
Option(\"".$Row['SubjectNo']."\");\n";
echo "select.opt ions[".$ctr."].value = \"".$Row['SubjectNo']."\";\n";
$ctr++;
}
?>
}
function Fill_Sub()
{
<?PHP
var mainselect = document.FormNa me.MainCategory ;
var subselect = document.FormNa me.SubCategory;
if( mainselect.opti ons[mainselect.sele ctedIndex].value != 0 ) {
subselect.lengt h = 0;
}
$Query = "SELECT SubjectNo, SubjectDesc, StatusID FROM Subjects WHERE
StatusID = 1 ORDER BY SubjectDesc ASC";
$Result = mysql_query($Qu ery, $conn );
while( $Row = mysql_fetch_arr ay($Result) ) {
?>
if( mainselect.opti ons[mainselect.sele ctedIndex].text == "<?PHP echo
$Row['SubjectNo']; ?>" ) {
<?PHP
$Query2 = "SELECT TopicID, TopicDesc, KS, SubjectNo FROM ttopic WHERE
StatusID = 1 AND SubjectNo = ".$row['SubjectNo']." ORDER BY TopicDesc ASC";
$Result2 = mysql_query($Qu ery2, $conn );
$ctr = 0;
While( $Row2 = mysql_fetch_arr ay($Result2) ) {
echo "subselect.opti ons[".$ctr."] = new
Option(\"".$Row 2['TopicID']."\");\n";
echo "subselect.opti ons[".$ctr."].value =
\"".$Row2['TopicID']."\";\n";
$ctr++;
}
?>
}
}
<?PHP
}
mysql_close($co nn);
?>
}
</SCRIPT>
</HEAD>
<BODY onload="BodyLoa d();">
<FORM name="FormName" method="POST" action="">
<TABLE border="1">
<TR>
<TD>Main Category</TD>
<TD>Sub Category</TD>
</TR>
<TR>
<TD>
<SELECT name="MainCateg ory" onchange="Fill_ Sub();">
</SELECT>
</TD>
<TD>
<SELECT name="SubCatego ry" size="4">
</SELECT>
</TD>
</TR>
</TABLE>
</FORM>
</BODY>
</HTML>
I have found the following script php/java for dynamic menu lists. Where a
selection from the first updates (filters items in) the other. I have
modified it for my tables.
However I am getting an error
Parse error: parse error, unexpected T_VAR in
e:\domains\i\id dsoftware.co.uk \user\htdocs\Qu estionDB\Questi ons.php on line
42
line 42 being
var mainselect = document.FormNa me.MainCategory ;
Im fairly new to php and dont use Java upto now. Can anyone see where I ve
gone wrong
<?php
session_start() ;
include("../include/connection.php" );
include("../Secure/login.php");
$Heading= 'QUESTION SELECTOR';
$Menu='<a href="../Secure/logout.php">Log out</a><br>';
include 'HeadQuest.php' ;
$Query = "SELECT SubjectNo, SubjectDesc, StatusID FROM Subjects WHERE
StatusID = 1 ORDER BY SubjectDesc ASC";
$Result = mysql_query( $Query, $conn );
?>
<HTML>
<HEAD>
<SCRIPT language="JavaS cript">
function BodyLoad()
{
var select = document.FormNa me.MainCategory ;
select.options[0] = new Option("Choose One");
select.options[0].value = 0;
<?PHP
$ctr = 1;
While( $Row = mysql_fetch_arr ay($Result) ) {
echo "select.opt ions[".$ctr."] = new
Option(\"".$Row['SubjectNo']."\");\n";
echo "select.opt ions[".$ctr."].value = \"".$Row['SubjectNo']."\";\n";
$ctr++;
}
?>
}
function Fill_Sub()
{
<?PHP
var mainselect = document.FormNa me.MainCategory ;
var subselect = document.FormNa me.SubCategory;
if( mainselect.opti ons[mainselect.sele ctedIndex].value != 0 ) {
subselect.lengt h = 0;
}
$Query = "SELECT SubjectNo, SubjectDesc, StatusID FROM Subjects WHERE
StatusID = 1 ORDER BY SubjectDesc ASC";
$Result = mysql_query($Qu ery, $conn );
while( $Row = mysql_fetch_arr ay($Result) ) {
?>
if( mainselect.opti ons[mainselect.sele ctedIndex].text == "<?PHP echo
$Row['SubjectNo']; ?>" ) {
<?PHP
$Query2 = "SELECT TopicID, TopicDesc, KS, SubjectNo FROM ttopic WHERE
StatusID = 1 AND SubjectNo = ".$row['SubjectNo']." ORDER BY TopicDesc ASC";
$Result2 = mysql_query($Qu ery2, $conn );
$ctr = 0;
While( $Row2 = mysql_fetch_arr ay($Result2) ) {
echo "subselect.opti ons[".$ctr."] = new
Option(\"".$Row 2['TopicID']."\");\n";
echo "subselect.opti ons[".$ctr."].value =
\"".$Row2['TopicID']."\";\n";
$ctr++;
}
?>
}
}
<?PHP
}
mysql_close($co nn);
?>
}
</SCRIPT>
</HEAD>
<BODY onload="BodyLoa d();">
<FORM name="FormName" method="POST" action="">
<TABLE border="1">
<TR>
<TD>Main Category</TD>
<TD>Sub Category</TD>
</TR>
<TR>
<TD>
<SELECT name="MainCateg ory" onchange="Fill_ Sub();">
</SELECT>
</TD>
<TD>
<SELECT name="SubCatego ry" size="4">
</SELECT>
</TD>
</TR>
</TABLE>
</FORM>
</BODY>
</HTML>
Comment