Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8182787
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T00:57:56+00:00 2026-06-07T00:57:56+00:00

I have a js variable with many functions, and I want to create in

  • 0

I have a js variable with many functions, and I want to create in one of them a global variable visible in another php file that load the js file.

How can I do that ?

Thanks for help.

Thaks for help : here’s an edit :

The variable has a dynamic value and is generated on event.keyCode I have tried in my js file:
window.selected_sku = null; in the top of the js file

and in the appropriate function :

window.selected_sku =  v;

In my php within javascript code, I have :

    if(window.selected_sku!=null){
        alert(window.selected_sku);
    }   

but I don’t get any alert !!

Help..

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T00:57:58+00:00Added an answer on June 7, 2026 at 12:57 am

    assign it to window

    window.variable = "this is a variable".
    

    when you include the js file you can access the variable in any file.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have many js methods that uses global variables like: function DoSomething() { var
I have a variable that I'm using many times in a class and as
so i have many controllers and many views. i want my variable @random_quote to
I want to share my session variables in PHP using many subdomains. I have
I have objects with many variables that I declare and explain in the comments.
I'm working on a project that is to simulate many functions seen in Microsoft
So .... There are obviously many questions that all have been asked about Singletons,
I have a multidimensional array that contains a variable number of sub arrays. Each
I have variables which are of double type I want them to be float
Possible Duplicate: How to access a variable in a PHP class that is set

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.