Add javascript function to div

Add javascript function to div

Hello,

I have this task...


  1. <a href="#" id="btn_1">trigger form</a>
  2. <div id="myform"></div>
and custom jaascript function:


  1. function generateForm() {
  2.       var form = document.createElement("form");
  3. form.setAttribute('method',"get"); // form method
  4. form.setAttribute('action',""); // form action url
  5. form.setAttribute('name',"frmName"); // form name
  6. form.setAttribute('id',"frmId"); // form ID
  7.        var inputCtrl = document.createElement("input");
  8. inputCtrl.type = "text";
  9. inputCtrl.name = "data";
  10.        inputCtrl.setAttribute('id',"txt");
  11.        var inputSubmit = document.createElement("input");
  12. inputSubmit.type = "submit";
  13. inputSubmit.name = "submit";
  14.        inputSubmit.setAttribute('id',"sbmt");
  15. inputSubmit.value = "Submit";
  16.        /* To bind created input control with created from */
  17.       form.appendChild(inputCtrl);
  18.        form.appendChild(inputSubmit);

  19.        /* To bind created form with current document body */
  20.       document.body.appendChild(form);
  21. }
The task is, when clicked the link ( #bnt_1 ) to display the form in DIV ( #myform )

Thе code below works, but not what I want.

  1. $('#btn_1').click(function() {
  2. generateForm();
  3. });

I want the form to be in DIV.

Is there any suggestion? 
Thanks!