<!--
Hi,
This is my code
I'm basiclly trying to Pass Values (variables) between PHP
and JavaScript using The Variable [[$num_Courses]]
I'm trying to pass the num_Courses from PHP to JavaScript
so when I click on checkall Function it checks all the
checkboxs I want
I'm using nested loops to create a table of:
Student Names | Test1 | Test2 | Test3 ......
. . . .
. . . .
. . . .
(((I'm gonna put it between 2 lines so you can know it)))
Depends on the entries I have.
................Help Me PLease..............
-->
<?php require ("sql.php" ?>
<HTML>
<SCRIPT LANGUAGE="JavaScript">
<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! -->
<!-- Begin
function checkAll($num_Courses) {
for (var j = 1; j <= $num_Courses; j++) {
box = eval("document.checkboxform.C" + j);
if (box.checked == false) box.checked = true;
}
}
function uncheckAll($num_Courses) {
for (var j = 1; j <= $num_Courses; j++) {
box = eval("document.checkboxform.C" + j);
if (box.checked == true) box.checked = false;
}
}
function switchAll($num_Courses) {
for (var j = 1; j <= $num_Courses; j++) {
box = eval("document.checkboxform.C" + j);
box.checked = !box.checked;
}
}
// End -->
</script>
<BODY background="bkgnd5.jpg">
<?php
// Translate Course_Name into Course_ID
// Search for Course_ID in Test_Dates Table
// Display fields 'Description' and 'Test_Dates' from Test_Dates Table w/checkboxes next to them.
// Once checkbox(es) are clicked, and submits form, UPDATE everything in the database (into table Test_Taken.
echo("<FORM METHOD=POST ACTION='inserttestdates.php'> <INPUT TYPE=HIDDEN NAME=Student_ID VALUE=$Course_ID>"
$SQL = "SELECT * FROM Student_Access WHERE Course_ID = '$Course_ID' Order by Student_ID";
$num_Courses = numSQL($SQL);
$count = 0;
while ($count < $num_Courses) {
$Student_ID_Array[$count] = rmSQL($SQL, $count, 'Student_ID');
$count = $count + 1;
}
$SQLSt = "SELECT * FROM feeds_student_info, Student_Access WHERE feeds_student_info.Student_ID = Student_Access.Student_ID and Course_ID = '$Course_ID'";
$numStudents = numSQL($SQLSt);
$count = 0;
while ($count < $num_Courses) {
$L_Name[$count] = rmSQL($SQLSt, $count, 'L_Name');
$F_Name[$count] = rmSQL($SQLSt, $count, 'F_Name');
$count++;
}
$SQL = "SELECT * FROM Test_Dates WHERE Course_ID = '$Course_ID'";
$num_Tests = numSQL($SQL);
$count = 0;
while ($count < $num_Tests) {
$DescriptionArray[$count] = rmSQL($SQL, $count, 'Description');
$Test_DatesArray[$count] = rmSQL($SQL, $count, 'Test_Dates');
$Test_IDArray[$count] = rmSQL($SQL, $count, 'Test_ID');
$count = $count + 1;
}
$SQL2 = "SELECT Course_Name FROM Course_Info WHERE Course_ID = '$Course_ID'";
$num_Records = numSQL($SQL2);
$count = 0;
while ($count < $num_Records)
{
$CourseNameArray[$count] = rSQL($SQL2, $count, 'Course_Name');
$count = $count + 1;
}
If ($num_Tests != "0"
{
echo("<INPUT TYPE=HIDDEN NAME=Course_ID VALUE=$Course_ID>"
echo("<INPUT TYPE=HIDDEN NAME=St_ID VALUE=$St_ID>"
echo("<INPUT TYPE=HIDDEN NAME=num_Tests VALUE=$num_Tests>"
echo("<INPUT TYPE=HIDDEN NAME=num_Courses VALUE=$num_Courses>"
$SQL222 = "SELECT * FROM Test_Taken WHERE Course_ID = '$Course_ID' AND Test_ID = '$Test_IDArray[0]' AND Student_ID = '$Student_ID'";
$num = numSQL($SQL222);
for($c = 0; $c < $num_Tests; $c++)
{
if ($num == 0)
{
$SQL = "INSERT INTO Test_Taken (Student_ID, Course_ID, Test_Taken, Test_Passed, Test_ID, File_Link) VALUES('$Student_ID', '$Course_ID', '$Test_Dates_Array[$c]', 'off', $Test_IDArray[$c], 'file.path')";
wSQL($SQL);
}
}
echo("<Center><Table Border = 4>"
$isChecked = "Checked";
$isUnChecked = "UnChecked";
for($c = 0; $c < $num_Tests; $c++)
{
echo("<TD bgcolor = 'aabbcc'><B>$DescriptionArray[$c] [ $Test_DatesArray[$c] ]</B></TD><TD bgcolor = 'black'></TD>"
echo("<TD><INPUT TYPE=checkbox NAME='Select_All' VALUE='$Test_IDArray[$c]' onClick=checkAll($num_Courses)> Check All </TD>"
echo("<TD bgcolor = 'black'></TD><TD><INPUT TYPE=checkbox NAME='Unselect_All' VALUE='$Test_IDArray[$c]' onClick=uncheckAll($num_Courses)> Uncheck All </TD><TD bgcolor = 'black'></TD></TR><TR><TD></TD></TR>"
}
echo("</TR>"
echo("</Table><BR><BR>"
echo("<Center><Table Border = 3>"
echo("<TR><TD bgcolor = 'aabbcc'></TD><TD colspan=4><Center><FONT SIZE=+1>Tests Available for $CourseNameArray[0]</FONT><Center></TD></TR>"
echo("<TR><TD>Student Name</TD>"
for($c = 0; $c < $num_Tests; $c++)
{
echo("<TD bgcolor='aabbcc'></TD>"
}
$count = 0;
/**********These are the loops that**************/
/**********Generates the table**************/
while ($count < $num_Courses)
{
echo("<tr><td><input type=checkbox Name=St_ID Value=$Student_ID_Array[$count]>$L_Name[$count], $F_Name[$count]</td>"
for($c = 0; $c < $num_Tests; $c++)
{
echo("<TD><CENTER><INPUT TYPE=checkbox NAME='Test_IDArray[]' VALUE='$Test_IDArray[$c]'> $DescriptionArray[$c] [ $Test_DatesArray[$c] ]</CENTER></TD>"
}
$count = $count + 1;
}
/***************************************/
echo("</TABLE><br>"
echo("<CENTER><INPUT TYPE=SUBMIT NAME=SUBMIT9 VALUE='Update Test Status'></CENTER>"
echo("</FORM>"
}
Else
{
echo("<BR><CENTER><FONT SIZE=+1>There currently are no tests assigned for this course. Please go to the 'Test Manager' module to assign tests for this course.</FONT></CENTER><BR>"
echo("<BR><CENTER><INPUT TYPE='button' VALUE='< Back' onClick='javascript:history.go(-1)'\n></CENTER>"
}
?>
</BODY>
</HTML>
Hi,
This is my code
I'm basiclly trying to Pass Values (variables) between PHP
and JavaScript using The Variable [[$num_Courses]]
I'm trying to pass the num_Courses from PHP to JavaScript
so when I click on checkall Function it checks all the
checkboxs I want
I'm using nested loops to create a table of:
Student Names | Test1 | Test2 | Test3 ......
. . . .
. . . .
. . . .
(((I'm gonna put it between 2 lines so you can know it)))
Depends on the entries I have.
................Help Me PLease..............
-->
<?php require ("sql.php" ?>
<HTML>
<SCRIPT LANGUAGE="JavaScript">
<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! -->
<!-- Begin
function checkAll($num_Courses) {
for (var j = 1; j <= $num_Courses; j++) {
box = eval("document.checkboxform.C" + j);
if (box.checked == false) box.checked = true;
}
}
function uncheckAll($num_Courses) {
for (var j = 1; j <= $num_Courses; j++) {
box = eval("document.checkboxform.C" + j);
if (box.checked == true) box.checked = false;
}
}
function switchAll($num_Courses) {
for (var j = 1; j <= $num_Courses; j++) {
box = eval("document.checkboxform.C" + j);
box.checked = !box.checked;
}
}
// End -->
</script>
<BODY background="bkgnd5.jpg">
<?php
// Translate Course_Name into Course_ID
// Search for Course_ID in Test_Dates Table
// Display fields 'Description' and 'Test_Dates' from Test_Dates Table w/checkboxes next to them.
// Once checkbox(es) are clicked, and submits form, UPDATE everything in the database (into table Test_Taken.
echo("<FORM METHOD=POST ACTION='inserttestdates.php'> <INPUT TYPE=HIDDEN NAME=Student_ID VALUE=$Course_ID>"
$SQL = "SELECT * FROM Student_Access WHERE Course_ID = '$Course_ID' Order by Student_ID";
$num_Courses = numSQL($SQL);
$count = 0;
while ($count < $num_Courses) {
$Student_ID_Array[$count] = rmSQL($SQL, $count, 'Student_ID');
$count = $count + 1;
}
$SQLSt = "SELECT * FROM feeds_student_info, Student_Access WHERE feeds_student_info.Student_ID = Student_Access.Student_ID and Course_ID = '$Course_ID'";
$numStudents = numSQL($SQLSt);
$count = 0;
while ($count < $num_Courses) {
$L_Name[$count] = rmSQL($SQLSt, $count, 'L_Name');
$F_Name[$count] = rmSQL($SQLSt, $count, 'F_Name');
$count++;
}
$SQL = "SELECT * FROM Test_Dates WHERE Course_ID = '$Course_ID'";
$num_Tests = numSQL($SQL);
$count = 0;
while ($count < $num_Tests) {
$DescriptionArray[$count] = rmSQL($SQL, $count, 'Description');
$Test_DatesArray[$count] = rmSQL($SQL, $count, 'Test_Dates');
$Test_IDArray[$count] = rmSQL($SQL, $count, 'Test_ID');
$count = $count + 1;
}
$SQL2 = "SELECT Course_Name FROM Course_Info WHERE Course_ID = '$Course_ID'";
$num_Records = numSQL($SQL2);
$count = 0;
while ($count < $num_Records)
{
$CourseNameArray[$count] = rSQL($SQL2, $count, 'Course_Name');
$count = $count + 1;
}
If ($num_Tests != "0"
{
echo("<INPUT TYPE=HIDDEN NAME=Course_ID VALUE=$Course_ID>"
echo("<INPUT TYPE=HIDDEN NAME=St_ID VALUE=$St_ID>"
echo("<INPUT TYPE=HIDDEN NAME=num_Tests VALUE=$num_Tests>"
echo("<INPUT TYPE=HIDDEN NAME=num_Courses VALUE=$num_Courses>"
$SQL222 = "SELECT * FROM Test_Taken WHERE Course_ID = '$Course_ID' AND Test_ID = '$Test_IDArray[0]' AND Student_ID = '$Student_ID'";
$num = numSQL($SQL222);
for($c = 0; $c < $num_Tests; $c++)
{
if ($num == 0)
{
$SQL = "INSERT INTO Test_Taken (Student_ID, Course_ID, Test_Taken, Test_Passed, Test_ID, File_Link) VALUES('$Student_ID', '$Course_ID', '$Test_Dates_Array[$c]', 'off', $Test_IDArray[$c], 'file.path')";
wSQL($SQL);
}
}
echo("<Center><Table Border = 4>"
$isChecked = "Checked";
$isUnChecked = "UnChecked";
for($c = 0; $c < $num_Tests; $c++)
{
echo("<TD bgcolor = 'aabbcc'><B>$DescriptionArray[$c] [ $Test_DatesArray[$c] ]</B></TD><TD bgcolor = 'black'></TD>"
echo("<TD><INPUT TYPE=checkbox NAME='Select_All' VALUE='$Test_IDArray[$c]' onClick=checkAll($num_Courses)> Check All </TD>"
echo("<TD bgcolor = 'black'></TD><TD><INPUT TYPE=checkbox NAME='Unselect_All' VALUE='$Test_IDArray[$c]' onClick=uncheckAll($num_Courses)> Uncheck All </TD><TD bgcolor = 'black'></TD></TR><TR><TD></TD></TR>"
}
echo("</TR>"
echo("</Table><BR><BR>"
echo("<Center><Table Border = 3>"
echo("<TR><TD bgcolor = 'aabbcc'></TD><TD colspan=4><Center><FONT SIZE=+1>Tests Available for $CourseNameArray[0]</FONT><Center></TD></TR>"
echo("<TR><TD>Student Name</TD>"
for($c = 0; $c < $num_Tests; $c++)
{
echo("<TD bgcolor='aabbcc'></TD>"
}
$count = 0;
/**********These are the loops that**************/
/**********Generates the table**************/
while ($count < $num_Courses)
{
echo("<tr><td><input type=checkbox Name=St_ID Value=$Student_ID_Array[$count]>$L_Name[$count], $F_Name[$count]</td>"
for($c = 0; $c < $num_Tests; $c++)
{
echo("<TD><CENTER><INPUT TYPE=checkbox NAME='Test_IDArray[]' VALUE='$Test_IDArray[$c]'> $DescriptionArray[$c] [ $Test_DatesArray[$c] ]</CENTER></TD>"
}
$count = $count + 1;
}
/***************************************/
echo("</TABLE><br>"
echo("<CENTER><INPUT TYPE=SUBMIT NAME=SUBMIT9 VALUE='Update Test Status'></CENTER>"
echo("</FORM>"
}
Else
{
echo("<BR><CENTER><FONT SIZE=+1>There currently are no tests assigned for this course. Please go to the 'Test Manager' module to assign tests for this course.</FONT></CENTER><BR>"
echo("<BR><CENTER><INPUT TYPE='button' VALUE='< Back' onClick='javascript:history.go(-1)'\n></CENTER>"
}
?>
</BODY>
</HTML>