开发者

javaservlet page

Can I submit a jsp form without using submit button but with a link? 开发者_开发知识库if possible how ? Please let me know as soon as possible. I am stuck with my project.


Sure ... you can do something like below:-

<form id="test" action="something">
    <a href="javascript: submitform()">Submit Form</a>
    </form>
    <script type="text/javascript">
    function submitform()
    {
      document.getElementById('test').submit();
    }
   </script>


Certainly you can. Just let the link URL point to an URL matching the servlet's <url-pattern> and then do the job in doGet() method of the servlet.

See also:

  • Our Servlets wiki page


Only submit buttons can really submit the form on their own.

Forms can only be submitted by links if the links have an javascript onclick event that submits the form. Another option is to use a special class attribute on the submit button to make it look like a link with CSS.


Have a look at this link: http://www.javascript-coder.com/javascript-form/javascript-form-submit.phtml

You can use javascript to submit a form with:

document.forms["myform"].submit();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜