I am trying to pass $post; a variable created in a mysql query, to javascript function showDiv. Currently this doesnt work.
$post = $row['id'];
?>
<script type="text/javascript">
function showDiv() {
var note = "<?php echo $post ?>";
document.getElementById("<?php echo $post; ?>").style.display = "inline";
}
</script>
<?php
$addnote = '<input type="button" value="addnote" onclick="showDiv()"><div id="'.$postid.'" style="display:none;" class="'.$postid.'"> WELCOME</div>';
But if I change $post
to have a html value e.g
$post = '11';
then this code works.
I am novice in javascript so please be gentle, Any help is greatly appreciated. Thank you.