Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

us JavaScript submit button to submit a form?

 
rick collette
Ranch Hand
Posts: 208
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
I have big trouble figuring this out. I am very new to
JavaScript. Here is what I need to do, Use the following button
to submit my struts form:

Really need to be enlightened on this.
regards
 
poornima balagopal
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
if you are using html tags for your jsp or to submit your page
you can do like this
first write a function like as followsin java script in the head tag.
/* function for submit */

function submitType()
{
document.forms[0].submit();

}
call the function in the onclick of the button.use normal button than submit button . if you specify any name for your form then give the same in the function class instead of forms[0].submit(); forms[0] will be set if there no name for form . it will take the first form.
Hope this will help you
all the best
 
rick collette
Ranch Hand
Posts: 208
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you very much for your reply.
I will try your advice.
Unfortunately my submit button is auto-generated like the following.
There is no name and value for it. Basically, I wish I can send the form and
be forwarded to one of dispatch action methods, "process". Can this be achieved?

regards,
 
David Yutzy
tumbleweed and gunslinger
Ranch Hand
Posts: 192
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a hidden field on the form called "method", then use javascript to dynamically change this value to the dispatch method you want to call.
something like (in the onClick event of the button):
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic