elem
09-25-2011, 03:39 AM
i'm trying to change hidden div's display to block if the certain conditions in php will be true. so what i have is:
<head>
<link rel="stylesheet" type="text/css" href="style.css" />
<?php if((isset($_GET['section'])) AND ($_GET['section']=="booking") AND (isset($_GET['action'])) AND ($_GET['action']=="edit")) {
$query = mysql_query("SELECT * FROM booking WHERE id='$id'");
while ($row = mysql_fetch_object($query)) {
$id=$row->id;
if($id=="1") {
echo("<script type=\"text/javascript\">
document.getElementById('mydiv').style.display = 'block';
</script>");
}
}
}
?>
</head>
but it doesn't work ..... when you view page's source in the browser, this is what comes up before the end of head section:
<script type="text/javascript">
document.getElementById('flavours').style.display = 'block';
</script>
so php seems to work, but js doesn't for some reason, i still can't see the #mydiv. what am i doing wrong guys ?
<head>
<link rel="stylesheet" type="text/css" href="style.css" />
<?php if((isset($_GET['section'])) AND ($_GET['section']=="booking") AND (isset($_GET['action'])) AND ($_GET['action']=="edit")) {
$query = mysql_query("SELECT * FROM booking WHERE id='$id'");
while ($row = mysql_fetch_object($query)) {
$id=$row->id;
if($id=="1") {
echo("<script type=\"text/javascript\">
document.getElementById('mydiv').style.display = 'block';
</script>");
}
}
}
?>
</head>
but it doesn't work ..... when you view page's source in the browser, this is what comes up before the end of head section:
<script type="text/javascript">
document.getElementById('flavours').style.display = 'block';
</script>
so php seems to work, but js doesn't for some reason, i still can't see the #mydiv. what am i doing wrong guys ?