/    Sign up×
Community /Pin to ProfileBookmark

lil help variables

hi,
i’ was a bit confused on which forum(javascript/php) i should put this in so i put it here:

basically what i have is a .phtml page with javascript and php in both work but what i want to do is assign a variable and then use it in the php file
and what i want to know is:
is this possible???????if yes how do you do it????

and is there any php statement that refers to javascript??????

i dont know because i only started working with php yesterday and it seems pretty flexable but with the $ in front of each variable it makes things confusing for me being a complete noob in php.

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@NogDogDec 21.2005 — Consider this sequence of events:

  • 1. The webserver parses your source file, executing any PHP code it finds.


  • 2. The result of that webserver parsing is an HTML document (which includes your JavaScript portions) which is sent to the browser on the user's machine.


  • 3. Upon loading that HTML document, the browser will display that page and may (if Javascript is enabled on that browser) execute any JavaScript included in the page.


  • Therefore, because of the sequence of things, it is relatively simple to have PHP affect JavaScript by doing things such as using PHP variables to set values within the JavaScript. It is much more problematic to do the reverse, as the JavaScript would have to send data to the host where PHP processing is done, then somehow get the results sent back to the browser.

    This [i]might[/i] be possible using the latest fad: Ajax. However, I'll leave that to the Ajax gurus as I know next to nothing about it. (I generally avoid doing anything with JavaScript, since - for accessibility reasons - I then have to do double work and come up with non-JavaScript solutions for users who do not have JavaScript available and enabled.)
    Copy linkTweet thisAlerts:
    @knowjDec 21.2005 — could you assign the varible to a hidden form element?
    ×

    Success!

    Help @jam 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 6.17,
    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: @nearjob,
    tipped: article
    amount: 1000 SATS,

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

    tipper: @meenaratha,
    tipped: article
    amount: 1000 SATS,
    )...