creating and submitting a form with javascript

前端 未结 4 492
春和景丽
春和景丽 2020-12-05 06:55

I\'m trying to create a form and submit it immediately with javascript and I cannot figure out what I\'m doing wrong. here is my code:

function autoLogIn(un,         


        
4条回答
  •  有刺的猬
    2020-12-05 07:50

    You also can do the Saurabh Chauhan response but without add the dinamic element to body This solution is all dinamic solution.

        var myform = document.createElement("form");
        myform.action = "myForm.aspx";
        myform.method = "post";
    
    
        product = document.createElement("input");
        product.value = "value";
        product.name = "name";
    
        myform.appendChild(product);
        myform.submit();
    

提交回复
热议问题