/    Sign up×
Community /Pin to ProfileBookmark

Javascript to interact with PHP

Hello guys, i’m new in this forum! I wanted to give a chance to drop a class and cookies to ensure it stays removed for the time that I have established.

Then, the cookie management I already know how to do it, to eliminate the class in PHP do not know, so I decided to use the API .fadeOut () to jQuery, so I gave a nice effect to the elimination (which hide rather than delete it, but let’s go). I wrote the code in this way, but it gives me problems (after I write the code that gives me problems):

[code=php]<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>

<html xmlns=”http://www.w3.org/1999/xhtml”>

<head>

<style>

p { font-size:150%; cursor:pointer; }

</style>

<script src=”http://code.jquery.com/jquery-latest.js”></script>

</head>

<body>

<?php

$chiudi = “<script language=javascript>$(“p”).click(function () {

$(“p”).fadeOut(“slow”);

});</script>”;

setcookie(“chiudi_avviso”, $chiudi, time()+3600);

$cookie = $_COOKIE[‘nome_utente’];

if (!$cookie) {

echo “<p>Clicca qui</p>”;

}

?>

</body>

</html>[/code]

So, not only when I click the javascript function does not appear (obviously I used the system creates an incompatibility) but if I update the text you see the same so the cookie does not start, then .. What is wrong?

I’m sorry for my bad english, i’m italian!

to post a comment
PHP

0Be the first to comment 😎

×

Success!

Help @Clear spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...