0
I have this Javascript function below, where I want to change the display
of a link if the value of a session variable is equal to a certain value.
However, this way that I did, it’s not working, still confusing me a lot when using Javascript and PHP.
Someone could help out?
And it would be possible to do this using only PHP for the user to load the page?
<script language="JavaScript" type="text/javascript">
document.onload=function mostraCampominha() {
var select = <?php echo $_SESSION['aprovado']?>;
var txt = document.getElementById("minha");
txt.style.display = (select.value == 'sim')
? "block"
: "none";
}
</script>
What is the value of $_SESSION['approved']? For the rest of your code it seems to be an object... If it is, try using json_encode in echo and javascript you do a JSON.parse at this value: var select = JSON.parse("<? php echo json_encode($_SESSION['approved'])?>");
– JuniorNunes
@Juniornunes The value of
$_SESSION['aprovado']
would be orsim
ornão
– Arthur Oliveira