JS is the language of the front desk, PHP is the background of the language, beginners will often appear before and after the situation (I was like this, and now sometimes committed), my original idea is to put the front and back Taiwan as two islands, they are unable to cross, HTML is like a bridge, When you want to pass a variable on an island to another island, you can only use this bridge.
Let me make a little summary:
1:html in the value of how to upload JS, the following assumption is file 1.php
Copy Code code as follows:
<html>
<body>
<form action= "1.php" method= "POST" >
name:<input type= "text" name= "username" id= "username" >
rename:<input type= "text" name= "username1" id= "username1" >
<input type= "button" value= "Submit" on click= "Get ()" >
</form>
</body>
</html>
JS If you want to take the text box in the user entered the name value, so write
Copy Code code as follows:
<script language= ' JavaScript ' >
function Get ()
{
var N=document.getelementbyid (' username '). value;
alert (n);
}</script>
in this case, the alert box pops up when there is a call to JS get (), and the contents are the value of name.
2: If you say JS in this take the name value to return to the Rename text box, so write
Copy Code code as follows:
<script language= ' JavaScript ' >
function Get ()
{
var N=document.getelementbyid (' username '). value;
document.getElementById ("username1"). Value=n;
}</script>
in this case, the call to get () will automatically display the value you entered in name above.
3:php The value of the page
I think everybody's going to be all right .
Copy Code code as follows:
<?php
$name =$_request["username"];
Echo $name;
?>
4:php The value of the message back to the page
Insert the PHP language in HTML, you can call the value of variables in PHP, also available smarty (recommended).
with these, whether it is the value of HTML pages or JS variables in the value, can be easily passed into PHP, of course, PHP value can also be reached where you want.