Introduction to the value of JS and PHP

Source: Internet
Author: User
Tags php language

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.