• 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
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

submit thru javascript

 
Ranch Hand
Posts: 325
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When you submit the form thru Java script, will the validation frame work properly.. Any special things, that need to be taken into consideration..
Suppose I have a select one submit button and a oridinary button in my JSP.
With submit button, validation works normally..
for the other button
we write some thing like this..

var form1 = document.abcForm;
form1.action ="XYZAction.do";
form1.submit();
Will the aboove one have the same effect as submit button as far as validation framewok is considered..
}
 
Ranch Hand
Posts: 228
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yeah the validation fwk will still be invoked if you use javascript to submit the form to a struts action.
 
manasa teja
Ranch Hand
Posts: 325
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No Sandy.. No luck.. Its not working for me !! I just called a javscript function, where in i am using same action... but, when i click on 2nd button( a NON-submit button)..
But its not working!!
Any suggestions..
var form1 = document.abcForm;
form1.action ="XYZAction.do";
form1.submit();
 
sandy gupta
Ranch Hand
Posts: 228
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
try document.form1.submit(); in the js function.
Make sure that the name of your action form is the name given to form1 which is the name that appears in the form tag of the source of the page.
It should work. :roll:
You do not have to do this
form1.action ="XYZAction.do";
and even if you want to, the way to do this is form1.action.value = "XYZAction.do";
[ November 21, 2003: Message edited by: sandy gupta ]
 
Ranch Hand
Posts: 390
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Sandy:
I think that only works for plain html. I had problem with submission some times last year when I successfully developed a demo calling Javascript submit() functions. When I started working on the main project, it did not work. I do not think the javascript submit() function actually submits to the server or the action class.
Unless you have done it sucessfully before then you should let us know how you did it.
Thx,
anselm.
 
sandy gupta
Ranch Hand
Posts: 228
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have done it Anslem and it does work.
function changeCountry()
{
document.RegisterForm.submit();
}
This is my method that i use to submit the form upon the change of the country value in a drop down list.
RegisterForm is the name of my form tag.
This submits the form to a struts url.
What all of us need to understand here is "struts behind the scene is simple old java" struts html tags, still get rendered as html and struts actions still are simple servlets.
Sahil
 
Anselm Paulinus
Ranch Hand
Posts: 390
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That is nice to know, but I do remember having some problem with this function before. Try it on some other browsers like Mozilla. Not just IE.
 
manasa teja
Ranch Hand
Posts: 325
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Anselm Paulinus:
Hi Sandy:
I do not think the javascript submit() function actually submits to the server or the action class.



I tried that.. no luck again . validation is not getting invoked...
As Anselm says, there is some difference between submitting form with submit button adn submitting thru a javascriipt. I asked similar question
Here also..
May be, i am doing some mistkes here ..
 
knowledge is the difference between drudgery and strategic action -- tiny ad
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic