I have a php file with a variable $total as one of its variable.
AS part of my project I have to print a table of results. I call an external javascript whenever i display the table, something like this
echo "<script src='course.js' language='JavaScript'></script>";
echo "<table border='1'>";
echo "<tr>";
echo "<td><td>";
Each row of this table has a checkbox, and i call the script file to check whether the number of checked boxes is not more than 8, for which i need the $total variable which is the total number of rows in the table
My course.js file looks like this (assuming $total)
var count = 0;
for(i=1;i<=$total;i++)
{
if(document.getElementByTag('course."i"').checked==true)
count++;
}
if(count==8)
{
for(i=1;i<total;i++)
{
document.getElementById('course."i"').disable=true;
}
}
}