/    Sign up×
Community /Pin to ProfileBookmark

Javascript variable to php?

Hi,

I am using some javascript on a php page to select colours so I can use my page to write a stylesheet. I have it working to the point that I can display the stylesheet text on the page. But I want to either write it to a file, or store it in a mysql database. Does anyone know how I can take the variable from javascript so I can use it with some php code on the same page?

Thanks in advance.

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@PittimannJun 14.2004 — Hi!

When your page "arrives" in the user's machine, all PHP has already been executed. So without sending the js data back to the server for storage you can't use your js variables.

You could have the user submit a form with the desired data, then process the form data server side and redirect to the page again, this time using the modified data.

Cheers - Pit
Copy linkTweet thisAlerts:
@TaipanauthorJun 15.2004 — Thanks for that. I should have worked that out myself.
×

Success!

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