• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

us JavaScript submit button to submit a form?

 
Ranch Hand
Posts: 208
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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,
 
tumbleweed and gunslinger
Posts: 192
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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):
 
I have always wanted to have a neighbor just like you - Fred Rogers. Tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic