transfering html or javascript variable to php
Posted: Sun Sep 12, 2004 4:18 pm
Ok, I'm making a quiz, and can't figure out how to keep score. Before I say anything else, here's the quiz, the php file in txt format, and a simplified version of the quiz:
http://minime001.net/quiz/
http://minime001.net/quiz/quiz.txt
top of page:
javascripts:
question buttons:
form:
Problem is, I can't see how to set a variable in php when you click one of the pics, and I can't see how to read a html/javascript variable with php. I was talking to a guy in IRC and he said to use this:
<?=' . PHP_SELF . '?>?q#<script>document.writeln(var);</script>
but then I had to go and didn't get to hear an explanation of how to use it. ^^;
Any ideas?
http://minime001.net/quiz/
http://minime001.net/quiz/quiz.txt
top of page:
Code: Select all
<?php
$page = (isset($_REQUEST['page'])) ? $_REQUEST['page'] : "";
$self = getenv("SCRIPT_NAME");
?>Code: Select all
if (document.images) {
cho= new Image(30,30);
cho.src="c.PNG";
rig= new Image(30,30);
rig.src="r.PNG";
wro= new Image(30,30);
wro.src="w.PNG";
nul= new Image(30,30);
nul.src="n.PNG";
}
var clicked = "no";
function switchImg(picName,imgName,nul1,nul2,nul3)
{
if (clicked == "no") {
if (document.images)
{
imgOn=eval(imgName + ".src");
documentїpicName].src= imgOn;
imgOn2=eval("nul.src");
documentїnul1].src= imgOn2;
imgOn3=eval("nul.src");
documentїnul2].src= imgOn3;
imgOn4=eval("nul.src");
documentїnul3].src= imgOn4;
}
clicked = "yes";
}
}Code: Select all
<img src="c.PNG" border="0" alt="" name="choose1" onmouseover="this.style.cursor='pointer';" onClick="javascript:switchImg('choose1','wro','choose2','choose3','choose4');" />
<img src="c.PNG" border="0" alt="" name="choose2" onmouseover="this.style.cursor='pointer';" onClick="javascript:switchImg('choose2','wro','choose1','choose3','choose4');" />
<img src="c.PNG" border="0" alt="" name="choose3" onmouseover="this.style.cursor='pointer';" onClick="javascript:switchImg('choose3','rig','choose1','choose2','choose4');" />
<img src="c.PNG" border="0" alt="" name="choose4" onmouseover="this.style.cursor='pointer';" onClick="javascript:switchImg('choose4','wro','choose1','choose2','choose3');" />Code: Select all
<form action="<?php print $self ?>" method="get">
<input type="hidden" name="page" value="q02" />
<input type="submit" value="Next Question" />
</form><?=' . PHP_SELF . '?>?q#<script>document.writeln(var);</script>
but then I had to go and didn't get to hear an explanation of how to use it. ^^;
Any ideas?