jeudi 5 février 2015

If statement JS not working

I have a small forum board on my website, which i have made myself. On it i am trying to add a rules post that sticks to the top. It uses Javascript at the moment to tell if it has been read or not via a cookie, If they have been acepted it won't show, if not they have to accept them.


But no matter what i do it will not show while in the if statement.



<script>
$rules_accepted = getCookie('accepted');
var admin_msg = "<div class=\"msg msg_admin\" style=\"margin-bottom: 15px;\">" +
"<span style=\"color: red; font-size: 1.25em; font-weight: bold;\">Admin</span><hr />" +
"<span style=\"font-size: 1.1em;\">Rules are to be followed and are enforced strictly.<br />Failure to follow the rules will result in an IP Ban from the site!<br /><br /><a href=\"javascript: showRules()\">Click here to view the Rules!</a></span>&nbsp;&nbsp;&nbsp;&nbsp;Not working? <a href=\"javascript: void(0)\">Try here</a> instead.<br /><br />" +
"</div>";

if ($rules_accepted != 1) {
document.write(admin_msg);
}
</script>


I know the getCookie('name'); function works because i have used it elsewhere in the page flawlessly. i also know that it is the if statement in some way, since if i simply use document.write(admin_msg) it shows up but not if the if statement surrounds it.



Before you ask to check if the cookie is already set to 1 i have done so already.


Aucun commentaire:

Enregistrer un commentaire