I have a small issue that's bugging me.
I have a BUTTON, which, when clicked, opens a "New Window", based on a JavaScript Function :
**<input type="button" id="button1" value="PLEASE BEGIN"
onclick="OpenWindow();">**
And, here is the JS function :
<script type="text/javascript">
function OpenWindow() {
window.open ('/MyFolder/newfile.php', 'newwindow', config='height=670,
width=1400, toolbar=no, menubar=no, scrollbars=no, resizable=no,
location=no, directories=no, status=no');
}
</script>
So, when the BUTTON is clicked, it calls the function, which opens the file "newfile.php" in a new window, with those parameters (height, width, etc, etc)
This works perfectly.............as long as I need to open the SAME file each time that button is clicked.
My problem is : the files differ. I want to open a "different" file each time that button is clicked.
In other words : how can I structure the JS function, so that it works the same way, IRRESPECTIVE of which file needs to be opened ???
(My program is designed to FETCH the required file directly from the database itself. This is why my current JavaScript function is useless. It opens the same file each time)
How can I fix this?
Thanks
UPDATE
Perhaps, I did not clarify my issue properly in my initial post.
My mistake.
Here's what I am trying to do :
(a) I'm creating a quiz program; (b) the questions are stored in the database, in a table called questions, which has only 3 columns :
ID (which is integer, and auto-incremential); question (the question itself) question_php (which contains the name of the PHP FILE which holds the question)
The reason I am using a database is : when a user answers each question, (whether correctly or wrongly), he proceeds to the NEXT question.
I designed my PHP script to store the ID of the LAST question answered.
So, the next time, the user logs in, he begins the quiz from the NEXT question in the database.
This way, he never sees the same question more than once.
My program is working fine, except for one thing : THE FIRST QUESTION :D
In the database, this first question has ID=1 (of course), and the question_php is : "1.php"
So, the "button" which is marked "PLEASE BEGIN"...........when clicked, the user is re-directed to "/MyFolder/1.php"
For example, if the user answers questions 1 to 5 correctly, and then stops..............the next time he logs in, and clicks PLEASE BEGIN, he is supposed to start from Question 6 (6.php).
This works............except for one small detail : the program fetches the correct ID ("6")............BUT..........the user is presented with the contents of Question 1 !
Right away, I realized that the cause of the problem was this statement :
<script type="text/javascript">
function OpenWindow() {
window.open ('/MyFolder/1.php', 'newwindow', config='height=670,
width=1400, toolbar=no, menubar=no, scrollbars=no, resizable=no,
location=no, directories=no, status=no');
}
</script>
No matter where the user begins the quiz, the JS function opens file "1.php"
And, the funny thing is : after "1.php".........the quiz continues as it should : question 7, question 8, etc
So, the only problem is the beginning; that very first CLICK.