Change value of input and submit form in JavaScript

前端 未结 8 1361
死守一世寂寞
死守一世寂寞 2020-11-30 03:20

I\'m currently working on a basic form. When you hit the submit button, it should first change the value of a field, and then submit the form as usual. It all looks a bit li

相关标签:
8条回答
  • 2020-11-30 03:36
    document.getElementById("myform").submit();
    

    This won't work as your form tag doesn't have an id.

    Change it like this and it should work:

    <form name="myform" id="myform" action="action.php">
    
    0 讨论(0)
  • 2020-11-30 03:38

    My problem turned out to be that I was assigning as document.getElementById("myinput").Value = '1';

    Notice the capital V in Value? Once I changed it to small case, i.e., value, the data started posting. Odd as it was not giving any JavaScript errors either.

    0 讨论(0)
提交回复
热议问题