Example 1
The code is as follows |
Copy Code |
var myForm = document.createelement ("form"); Myform.method= "Get"; Myform.action = "line_ticket.aspx"; var myinput = document.createelement ("input"); Myinput.setattribute ("name", "id"); Myinput.setattribute ("value", IDSTR); Myform.appendchild (Myinput); var myInput2 = document.createelement ("input"); Myinput2.setattribute ("name", "FID"); Myinput2.setattribute ("value", FID); Myform.appendchild (MYINPUT2); var myInput3 = document.createelement ("input"); Myinput3.setattribute ("name", "unlock"); Myinput3.setattribute ("value", unlock); Myform.appendchild (MYINPUT3); var myInput4 = document.createelement ("input"); Myinput4.setattribute ("name", "option"); Myinput4.setattribute ("Value", "Del"); Myform.appendchild (MYINPUT4); Document.body.appendChild (MyForm); Myform.submit (); Document.body.removeChild (MyForm); |
Example 2
The code is as follows |
Copy Code |
<script type= "Text/javascript" > function Postwith (to, p) { var myForm = document.create_r_r_relement_x ("form"); Myform.method = "POST"; Myform.action = to; For (var k in P) { var myinput = document.create_r_r_relement_x ("input"); Myinput.setattribute ("name", K); Myinput.setattribute ("value", p[k]); MYFORM.A (Myinput); } DOCUMENT.BODY.A (MyForm); Myform.submit (); Document.body.removeChild (MyForm); } </script>
|
Code for Hyperlinks:
The code is as follows |
Copy Code |
<a href= "Javascript:postwith (' datatest.action ', {' currentpage ': ' 2 ', ' Xisuo ': ' Computer '})" >use JS to Post</a>
|
When you click the hyperlink, you can send the value of CurrentPage and Xisuo to the datatest.action for processing, especially when handling multiple parameters.