Forum Moderators: coopster
The problem is the following:
I have a form where the user inserts a query, e.g :"Retrieve all tha names of the students".
The next page, which is written in PHP gets the result, e.g: "Nick", "John", "Mary".
What I want to do is to have something like a small box near each name, which the user can tick and then see the student's page for examlpe.
It is sort of a 'select button', and the user can select one or more students to view their pages.
Q1: Is this done with Javascript only or can I use PHP as well?
Q2: Because I don't know anything about Javascript, is there any short code that can do my job easily?
Thanx in advance
Let's start with a really simple version. Let's assume that you want list all students and, when someone checks the box, it opens a popup with their page on it.
$student_list = "<form method="post" name="myform" action=""><ul>";$q = "SELECT id, name, url FROM students";
$r = mysql_query($q);
while ($student = mysql_fetch_assoc($r))
{
$student_list .= '<li><input type="checkbox" name="'. $student['id'] onclick="window.open(\'' . $student['url'] . '\')" /> ' . $student['name'] . '</li>';
}$student_list .= "</ul></form>";
I don't know whether that gets you part way there, at least conceptually. You will likely want the onclick to call a function that you have defined elsewhere that can do more complex things (like show and hide a screenshot of the page or some such thing).