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

  • SEARCH
  • Home
  • 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 8381781
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T16:46:20+00:00 2026-06-09T16:46:20+00:00

Possible Duplicate: How can I use a JavaScript variable as a PHP variable? I

  • 0

Possible Duplicate:
How can I use a JavaScript variable as a PHP variable?

I need to use javascipt variables in PHP, how can I do that?

eg:

<script>
var abc = 'this is text';
</script>

How can I read variable abc in php?

  • 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-09T16:46:21+00:00Added an answer on June 9, 2026 at 4:46 pm

    One way of doing it is to make use of a hidden text/input box.

    <input type="text" style="display:none" id="hiddenVal" />
    

    In the Javascript assign the variable to the input box.

    <script>
    function loadValues()
    {
    var abc = 'this is text';
    document.getElementById("hiddenVal").value = abc;
    //alert(document.getElementById("hiddenVal").value);
    }
    </script>
    
    <body onload="loadValues();">
    
    <form action="processing.php" method="post">
      <input type="text" style="display:none" id="hiddenVal" />
      <input type="submit" name="submit" id="submit" value="Submit" />
    </form>
    </body>
    

    This is one method to allow you to use Javascript variable and post it to the backend. Alternatively if you want to display these values just remove the

    style=”display:none”

    on the control.

    Now after the post occurred one should be able to pick up the variable using processing.php

    <?php
    echo $_POST["hiddenVal"];
    ?>
    

    Very dirty way of doing this but does the trick.

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

Sidebar

Related Questions

Possible Duplicate: Javascript Variable Variables There's a really handy thing in PHP (that I'm
Possible Duplicate: Can I use a generated variable name in PHP? Am stuck here!
Possible Duplicate: Can you use $_GET variables when including a file in PHP? Is
Possible Duplicate: How can I detect the browser with PHP or JavaScript? I need
Possible Duplicate: How to use javascript variables in jquery selectors This works $('input[name=nickname]').css(...); Now
Possible Duplicate: How can one use multi threading in php applications Does anybody know
Possible Duplicate: Deflate command line tool Yes, I know I can use PHP itself
Possible Duplicate: replace all occurrences in a string I found this question/answer: Use JavaScript
Possible Duplicate: Use of 'prototype' vs. 'this' in Javascript? I am confused with these
Possible Duplicate: Use the get paramater of the url in javascript How can I

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.