Lie down. How to get data from an HTML form form in the simplest way __html

Source: Internet
Author: User
Tags html form

Recently, the Internet has been not very good ~ ~ ~ Unhappy

This article is the simplest way, only for their own testing, after all, there are some unsafe factors.

See the other good way to find all too troublesome, so I summarized.

Is this: there is a piece of code in the Input.html page.

The code contains a form, another index.html page that is filled in action to receive data. Use Get method.

Form form contains an input label below.

When you click Submit, our URL is passed through the address bar to the index.html page.

<form action= "index.html" method= "get" > 
 homepage:<input type= "url" name= "User_url" > 
 <input Type= "Submit"/> 
</form>

Now we're going to get the information we sent over the index.html page.

<p id= "text" name= "text" >a</p> 
<script> 
var text=window.location.search; 
Gets the value of the following parameter Var loc=text.substring (text.lastindexof ("=") +1,text.length); 
document.getElementById (' text '). Innerhtml=loc; 

Here's the code I wrote: First of all, there must be a place to display our data, I use the P tag, what the label does not care, it is important to give him an ID.

Window.localtion.search represents the Get address bar. and the following parameters.
   such as: index.html?id=1&uname=2
       window.localtion.search to obtain is? id=1&uname=2

And sometimes we use the window.localtion.href is to get index.html?id=1&uname=2 the entire address bar

This method can be used to get our parameters, now to do is to remove?

It's too much trouble to look at other people's regular expressions.

Direct substring is OK. Look at the need data in front of that one is what, generally. or =

and then from. or = The following number begins to intercept until the last

Text.substring (text.lastindexof ("=") +1,text.length);

All right. You can do it.



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.