Php/Javascript pop up dynamic variable.

Hi Experts,

I need help with this, what im after is a Javascript pop up window which will let me Dynamicly define a PHP variable. if thats possible.

The variable i would like to try and define is.

below in my code called "$devideby ="

i dont have a clue how to do this as javascript pop up so really am in the dark. if you could help me with this it would be appricated. the variable of $devideby will be set as a number if that helps from 1 - 12.

many thanks for your time.

p.s if you know of a way of doing this just using php then please tell me. It needs to be set everytime you visit the page. and then the page updated with the variable after it has been set to show the "correct maths"

exmaple would be $variable 1 / $devide by = $variable 3

many thanks again.
$digits =2;
	$out_fee = $sum_total;
	$avgyr = $sum_total;
	$cutoff = pow(10, $digits);
	$divideby = 
	$rounded2 = round($avgyr * $cutoff / $divideby) / $cutoff;
	echo "<html><font color=' #003F87'><strong>£".$rounded2;"</strong></font></html>";

Open in new window

LVL 6
NeoAshuraAsked:
Who is Participating?
 
Dave BaldwinFixer of ProblemsCommented:
I have no idea what that means.  For PHP to generate a page using a variable value, it must have that value when the page is 'called', either thru a POST or a GET from the previous page or from another value stored somewhere.  And it needs it when it generates that page.  Javascript is Not Java, two different languages.
0
 
Dave BaldwinFixer of ProblemsCommented:
You can't set a PHP variable with javascript because PHP runs on the server to create the page before the javascript runs in the browser that displays the page.  After a page is loaded, you can use AJAX to pass a value back to a PHP script but that is still after the page has already loaded.
0
 
NeoAshuraAuthor Commented:
so the best way would be to create a dynamic variable using PHP rather than Java?
0
 
NeoAshuraAuthor Commented:
used post
0
 
Dave BaldwinFixer of ProblemsCommented:
Cool, thanks.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.