About 372,000 results
Open links in new tab
  1. How can I use a JavaScript variable as a PHP variable?

    Mar 13, 2015 · I'm trying to include JavaScript variables into PHP code as PHP variables, but I'm having problems doing so. When a button is clicked, the following function is called: <script type="text/javas...

  2. How do I pass JavaScript variables to PHP? - Stack Overflow

    Jul 15, 2016 · Now JavaScript directly interacts with DOM and can manipulate the layout but PHP can't - it needs to refresh the page. The only way is to refresh your page to and pass the parameters in the page URL so that you can get the data via PHP. So, we use AJAX to get Javascript to interact with PHP without a page reload. AJAX can also be used as an API.

  3. How do I pass variables and data from PHP to JavaScript?

    Apr 18, 2017 · 2. Echo the data into the page somewhere, and use JavaScript to get the information from the DOM. This method is less preferable to AJAX, but it still has its advantages. It's still relatively separated between PHP and JavaScript in a sense that there is no PHP directly in the JavaScript. Pros

  4. how to use PHP variable in Javascript - Stack Overflow

    Apr 19, 2016 · Well, not quite. it's not the PHP variable. It's a JS variable which might have the same name and has the same value. But the PHP variable does not exist anymore at that time. If JS changes the value of the variable, theres no feedback to any PHP variable, as it …

  5. Access PHP variable in JavaScript - Stack Overflow

    Though I'm 12 years late, though, people if you should not use this as the user can simply edit the value passed by php to js – Merlin the Immortal Commented Jul 20, 2023 at 14:36

  6. Get variable from PHP to JavaScript - Stack Overflow

    Jan 20, 2016 · However, I think the mixture of languages here is sloppy, and should be avoided where possible. I can't really think of any good reasons to mix data between PHP and JavaScript anyway. It really boils down to this: If the data can be obtained via JavaScript, use JavaScript. If the data can't be obtained via JavaScript, use AJAX.

  7. how to assign javascript variable value to php variable

    I have a better solution: Here, in the .php file, I have a variable called javascriptVar. Now, I want to assign the value of javascriptVar to my php variable called phpVar. I do this by simply call javascript variable by document.writeln in the script tag.

  8. Access a JavaScript variable from PHP - Stack Overflow

    @Chris Armstrong jquery is a great choice, and absolutely I think it would be better to use a regular button instead of the form submit button, use jquery to bind a function to the button's "click" event, and at that point capture the geolocation and then use javascript to submit the form.

  9. Pass a PHP variable to a JavaScript variable - Stack Overflow

    Now you can use the JS variable "moonUnitAlpha" anywhere you want to grab that PHP string value. This seems to work really well for us. We'll see if it holds up to heavy use.

  10. How to use javascript variables in PHP - Stack Overflow

    Aug 11, 2012 · 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'; </scr...

Refresh