Friday, 9 August 2013

Refresh html page using jquery

Refresh html page using jquery

**Hi everyone,
Clicking the button should refresh the page and display a change of
variable $TEST in the DEBUG-STATEMENT, but it doesnt ! What do I do wrong
?**
// ===== Start of the html-page: initialisation of var TEST=1 ===============
if ( !isset($_SESSION['TEST']) )
{
$_SESSION['TEST'] = 1;
}
echo "DEBUG STATEMENT: _SESSION(TEST) = ".$_SESSION['TEST'] ;

<?php
// ===== The BUTTON on the HTML-page ========================
if ($_SESSION['TEST'] = 1)
{
echo '<button type="button" id="button">Ja</button>';
} else {
echo '<button type="button" id="button">Nee</button>';
}
?>

// ===== The jQuery click function ==========================
<script type="text/javascript">
$("#button").click(function()
{
if ($(this).text() == "Ja")
{
$(this).text("Nee");
$_SESSION['TEST'] = 0;
location.reload();
}
else
{
$(this).text("Ja");
$_SESSION['TEST'] = 1;
location.reload();
};
});
</script>

No comments:

Post a Comment