2
Good morning! I have a problem, and I’m having trouble solving it. I need a buttom to appear or not according to the PHP condition. To make the buttom appear I’m succeeding, the point is that inside it has a javascript call that doesn’t work within PHP. I don’t know what I’m doing wrong.
Follow the codes:
<header>
<script type="text/javascript">
function exibe(id) {
if(document.getElementById(id).style.display=="none") {
document.getElementById(id).style.display = "inline";
}
else {
document.getElementById(id).style.display = "none";
}
}
</script>
</header>
<body>
<?php
if (get('data_do_descredenciamento')!= ''){
echo '<button type="button" class="btn" href="#" onclick="javascript: exibe('conteudo');">SUBSTITUTO</button>';
}
?>
</body>
It is giving error in the content: onclick="javascript: exibe('conteudo')
Could someone help me, please?
What is this
conteudo
? is a string? You have to escape those simple quotes... like this:exibe(\'conteudo\');
– Sergio