I want to change a session value and a <p> text using submit type button.
However, the session does changed, but the text not changed.
Here's the PHP codes inside the body.
<?php
if (isset($_POST['lang']) == true && !empty($_POST['lang'])) {
$_SESSION["language"]=$_POST['lang'];
}
?>
<p>My Name is Khan</p>
<form action="<?php echo htmlspecialchars($_SERVER['PHP_SELF'])?>" method="post">
<button type="submit" name="lang" value="jpn" id="jpn">日本語</button>
<button type="submit" name="lang" value="eng" id="eng">English</button>
</form>
Here's the Javascript codes
$(document).ready(function(){
$("#jpn").on('click', function(){
$("p").text("私の名前はハーンです");
});
$("#eng").on('click', function(){
$("p").text("My name is Khan");
});
});
When I click the Japanese button, the text changed for a flash but changed back to the original.
How can I fix this?
thank you..