Home>

When the page layout is somewhat complicated,You may need to create a form dynamically in the page. The JavaScript creation form is demonstrated as follows:

//javascript build a form
function makeform ()
{
  //create a form
  var form1=document.createelement ("form");
  form1.id="form1";
  form1.name="form1";
  //add to body
  document.body.appendchild (form1);
  //create an input
  var input=document.createelement ("input");
  //Set the corresponding parameters
  input.type="text";
  input.name="value1";
  input.value="1234567";
  //Insert the input box into the form
  form1.appendchild (input);
  //form submission
  form1.method="post";
  //form submission path
  form1.action="/servlet/info";
  //execute the form
  form1.submit ();
  //delete the form
  document.body.removechild (form1);
}

Once makeform is called, a form is created, submitted, and then the form is removed.

  • Previous PHP multidimensional array traversal method (2 implementation methods)
  • Next Android gravity sensor implements rolling pinball