Ok so I have a PHP variable I called on top of my document which is <? $mark = 0 ?>
now when you click on the classes of content-1 and so on I want to change the value of that PHP variable. How can I do that? I know that it has to be done in Javascript because I want to change it upon a "click" which can only be determined with javascript.
My Code:
<!DOCTYPE html>
<html lang="en">
<head>
<? $mark = 0; ?>
<meta charset="UTF-8">
</head>
<body>
<div class="content-1">
<? if( $mark == 1 ){ ?>
<p>This is content One!</p>
<? } ?>
</div>
<div class="content-2">
<? if( $mark == 2 ){ ?>
<p>This is content Two!</p>
<? } ?>
</div>
<div class="content-3">
<? if( $mark == 3 ){ ?>
<p>This is content Three!</p>
<? } ?>
</div>
<script>
$(document).ready(){
$(".content-1").click(function(){
//my attempt on changing the PHP variable $mark to 1
document.write( "<? echo $mark = 1; ?>" );
});
}
</script>
</body>
</html>
My code above generated a white screen with the number 1 on the top left hand corner when I click on content-1
Help is greatly appreciated, thank you.