Jump to content

EASY FOR YOU (php javascript) !!


faure
 Share

Recommended Posts

spirit of my code :

<html>
        
here a button on click for script

here an element <p with id="demodemo"

 

<script type="text/javascript">
    
    function myFunction() 
 
    {
    
    var abc= "REF1";

    document.getElementById('demodemo').innerHTML =  abc;

        ?php
    
        here I need abc
        how ?
        is there 2 methods ?

        thanks for your help


        ?>
  
    }

</script>

</html>

Link to comment
Share on other sites

Javascript cannot pass data to PHP.

PHP runs first on the server, generates Javascript code and then sends that Javascript code to the browser to be executed. If you need any server-side work done after that then you will have to use AJAX. Here is the AJAX tutorial: https://www.w3schools.com/js/js_ajax_intro.asp

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...