In the HTML static page button link, give the button plus the submitted link and so on method

Source: Internet
Author: User
Tags id3
1, the button made the link (picture) appearance


Submit button <input type= "Submit" value= "submitted" >


Submit link <a href= "#" onclick= "form name. Submit ()" > Submit </a>


Reset button <input type= "reset" value= "reset" >


Reset link <a href= "#" onclick= "form name. Reset ()" > Reset </a>


Normal button <input type= "button" value= "buttons" onclick= "function ()" >


Normal link <a href= "#" onclick= "function ()" > Links </a>


As for the picture, replace a label with IMG.


2, link to make the appearance of the button


<a href= "reg.asp" > Registration </a>


=><input type= "button" value= "registered" onclick= "location.href= ' reg.asp '" >

-----------------------------------

Sometimes we can do a get form manually, as with buttons or links.

<form action= "xx.asp" method= "Get" Name= "Form1" >


<input name= "AA" type= "text" id= "AA" >


<input name= "BB" type= "text" id= "BB" >


<input type= "Submit" name= "Submission" value= "submitted" >

</form>

=>

<input name= "AA" type= "text" id= "AA" >


<input name= "BB" type= "text" id= "BB" >


<input type= "button" value= buttons "onclick=" location.href= ' xx.asp?aa= ' +document.all[' AA '].value+ ' &bb= ' + document.all[' BB '].value >


-----------------------------------


Further said that we can also do a button (link) to pass the JS variable, form input value, ASP variables, recordset value


<script language= "JavaScript" >


var id1=1;


</script>


<%


Id3=3


....


Rs.Open exec,conn,1,1


Suppose to have RS ("Id4") =4


...


%>


<input name= "Id2" type= "text" id= "Id2" value= "2" >


<input type= "button" value= "buttons"


onclick= "location.href= ' xx.asp?id1= ' +id1+ ' &id2= ' +document.all[' id2 '].value+ ' &id3=<%=id3%>& Id4=<%=rs ("Id4")%> ' ">


We press the button to see the browser URL is xx.asp?id1=1&id2=2&id3=3&id4=4


In the xx.asp we can use Request.QueryString to get all the variables, so it is not a disguised client JS and the server segment of the variable pass.


--------------------------------------------------------------------------------------------------------------- ---------------

How to add a link to a button

Solution Idea:

A button is a control-level object that has a higher precedence, so it cannot be directly linked like a picture or text, and can only be achieved by invoking the script in the Click event of a button.

Specific steps:

1. Open the link in the original window

<input type= "button"


Value= "Flash" onclick= "location= ' http://www.xxx.net '" >

<button onclick= "location.href= ' http://www.xxxx.net '" > Flash bar </button>

<form action= "http://www.xxxx.net%22%3e%3cinput/type=" Submit "value=" Open link "></form>

2. Open a link in a new window

<input type= "button"

Value= "Flash" onclick= "window.open" (' Http://www.xxxx.net ') ">

<button onclick= "window.open (' http://www.xxxx.net ')" >ggg</button>

<form action= "http://www.xxxx.net/"


target= "_blank" ><input type= "Submit" value= "Open link" ></form>


Note: The quotation marks in the code of the onclick call can be nested only once in a single weight, and the quotes must be escaped with the "\" and the escaped quotation marks must conform to the inner quotation marks, such as:


<button onclick= "this.innerhtml= ' <font color=\ ' red\ ' >http://www.xxxx.net</font> '" > Flash </ Button>

Or

<button onclick= ' this.innerhtml= ' <font color=\ ' red\ ' >http://www.xxxx.net</font> ' > Flash </ Button>


And the following are the wrong wording:


<button onclick= "this.innerhtml= ' <font color= ' red ' >http://www.xxxx.net</font> '" > Flash </button >


<button onclick= "this.innerhtml= ' <font color=" red ">http://www.xxxx.net</font>" > Flash </button >


<button onclick= "this.innerhtml= ' <font color=\" red\ ">http://www.xxxx.net</font>" > Flash </ Button>


Tip: Most methods and properties that belong to the window or Document object can omit the prefix window or document, such as the location.href in this example ( Location.href can also be abbreviated as location, because location's default object is href) is the window.location.href or document.location.href ellipsis.


Tip: In this case, you can also use the following method instead of Location.href


Location.replace (URL)


Location.assign (URL)


Navigate (URL)


Special Tips


After the code in the first step runs, the click button jumps to the link target. The second step opens the link in a new window after the button is clicked.


Special Notes

The main example is to open the link by capturing the user's Click event on the button with onclick, and then calling the Location object's Href method or the Window object's Open method. Another trick is to implement the link function by submitting the form, the button must be a type=submit type of button, the action value of the form is the link target, and the target is the way the link is opened.

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.