/    Sign up×
Community /Pin to ProfileBookmark

Okay I have a div, and in its onclick function I want it to call a php function in the head. How can I do that? And by function I mean, one of my own, not one of php special functions. Basically, in this function I want to assign some values to variables. How can I do this(the calling of the function thing)?

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@MstrBobAug 16.2004 — Since PHP is preprocessed (meaning that all PHP script is executed before being sent to the client (browser)) It cannot execute based on on-page user-excutions, unless the browser requests another PHP page. That's what client-side scripting is for. If you want to call a PHP function onclick, you'd have to do something like:

<div onclick="window.location="currentpage.php?div=true"></div>

currentpage.php being that current page. At the top of the page you have:

<?PHP

myfunction()

{

/*your function stuff here*/

}

if(isset($_GET['div']) && $_GET['div']===true)

{ myfunction(); }

?>

But it can't be triggered without a reload.
Copy linkTweet thisAlerts:
@theuedimasterauthorAug 16.2004 — okay thanks
×

Success!

Help @theuedimaster 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.7,
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,
)...