What I am trying to do is creating a new form dynamically based on some input, once that is done I have given a submit button to submit the form.

Here's the code:

```
function add(index_array) {
    //create the form
    var myform = document.createElement("form");
    myform.id="k_form"
    for ( i =0 ; i <index_array.length ; i ++)
    {
        var mytext = document.createElement("input");
        mytext.tpye="text";
        mytext.value=index_array[i];
        mytext.id=index_array[i];
        myform.appendChild(mytext); 

    }
    var mybutton = document.createElement("input");
    mybutton.type="button"
    mybutton.value="submit"
    myform.appendChild(mybutton);
    mydiv=document.getElementById("d_div");
    mydiv.appendChild(myform);
}

```

This creates the form, now I am trying to process the inputs to this form when the user clicks submit.

How can i do that?

I was thinking I could call the function

```
document.forms["myform"].submit() 

```

But how can I make it trigger when user clicks submit?

Please help :)