• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

do i have to submit all the time

 
Leonardo Go
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i made a page with a form and button in it.
is it possible? that when i click on the button something will happen
(process stuffs) without submitting the form ?
thnx ...
 
Vijay Vaddem
Ranch Hand
Posts: 243
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not Exactly,

you may do your processing using a javascript function. When you click on
the button, invoke the javascript function.

Vijay
 
Vijayendra V Rao
Ranch Hand
Posts: 195
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Leo,

Like Vijay has replied, write a JavaScript function that will return either true or false based on what you want to do (I mean, the processing that you spoke about). Then, have the following syntax for your form's onsubmit() function:



So, the form will be submitted only if the JavaScript function validateForm( ) returns true
 
Leonardo Go
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
but can i call a java function i wrote in the jsp using javascript ?
because i was thinking of reacting events using java code instead of javascript.
but i think its not posible right ?
 
Vijayendra V Rao
Ranch Hand
Posts: 195
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Leonardo Go:
but can i call a java function i wrote in the jsp using javascript ?


As far as I know, you cannot call a Java method from a JavaScript function.
 
pascal betz
Ranch Hand
Posts: 547
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the JSPs are residing on the server and can only be reached trough HTTP(S) calls so there is no way to invoke your JSPs but to send a HTTP request (by clicking a link or by submitting a form or by some javascript code).


pascal
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I suppose this thread could find a home in either the JSP forum or the HTML and JavaScript forum.

(Flipping coin...)

Moving this to the HTML and JavaScript forum...
 
Julian Kennedy
Ranch Hand
Posts: 823
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Leonardo,

What you want to do is to submit each action (e.g. add, remove, save, close, etc.) to the server side (your JSP) and handle it there with a controller. The controller, another JSP or perhaps a servlet, which is on the server-side, can then get the supplied action from the request object and call the appropriate Java method to handle the action (do the processing).

You might want to Google for the "Model View Controller" design pattern, which is a time-honoured tradition of achieving the above.

Jules
 
Leonardo Go
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
things clearing up now .. thnx a lot
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic