JavaScript value to PHP Array?

Soldato
Joined
30 Nov 2005
Posts
3,086
Location
London
Hey,

Can anyone help me pass a JavaScript value to PHP.

It's based around jQuizMe script. I'm trying to pass the JavaScript value to a new page, so I can do what I like with it in PHP.

quizInfo.numOfRight is the JavaScript array of the value of the persons final quiz score is stored in.

PHP:
if( quizInfo.hasQuit ){

			SOMETHING HERE with quizInfo.numOfRight

		}

I'm thinking that perhaps we will need to redirect the person to another page when quizInfo.hasQuit is ran, then storing the JavaScript value into a PHP Array.

But rather confused about how I go about it.

Thanks
 
Thanks for your help.

This does seem like a very long winded process.

Is there nothing simpler?

Like once
PHP:
if( quizInfo.hasQuit ){
is executed could I not pass it into a FORM and use POST?
 
Last edited:
Could something along these lines work?

PHP:
		if( quizInfo.hasQuit ){
			
document.getElementById('scores').value=quizInfo.numOfRight;
		}

Then further below:

PHP:
<input name="scores" type="text" value="scores" size="10" readonly/>

Though I think there's something I'm missing above.
 
BOOM! Worked it out!

PHP:
if( quizInfo.hasQuit ){
document.forms['f1'].score.value = quizInfo.numOfRight;	
		}

PHP:
<form name='f1'>
		<input name="score" type="text" value=""  readonly/>
</form>

Works perfectly!

Now I can submit it using PHP and POST :D

Thanks all!
 
Back
Top Bottom