I want to dynamically tell a javascript which <div> to hide, but I dont know how to send the request to the javascript as it is a client side script.
for eg:
<?
$divtohide = "adiv";
?>
<script language="javascript">
function hidediv($divtohide) {
................
}
</script>
Assuming
$divtohideactually contains the ID of a<div>element and not a JavaScript variable name, write your JavaScript function as normal:And print out the PHP variable only when you’re calling it, within a pair of quotes:
addslashes()ensures that quotes"in the variable are escaped so your JavaScript doesn’t break.