wood burning stoves 2.0*
The moose likes HTML, CSS and JavaScript and the fly likes do i have to submit all the time Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "do i have to submit all the time" Watch "do i have to submit all the time" New topic
Author

do i have to submit all the time

Leonardo Go
Greenhorn

Joined: Jun 13, 2004
Posts: 13
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 ...


Problems are made to be solved.
Vijay Vaddem
Ranch Hand

Joined: Feb 13, 2004
Posts: 243
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

Joined: Jul 04, 2004
Posts: 195
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


Vijayendra <br /> <br />"The harder you train in peace, the lesser you bleed in war"
Leonardo Go
Greenhorn

Joined: Jun 13, 2004
Posts: 13
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

Joined: Jul 04, 2004
Posts: 195
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

Joined: Jun 19, 2001
Posts: 547
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

Joined: Dec 10, 2001
Posts: 7023
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...


[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
Julian Kennedy
Ranch Hand

Joined: Aug 02, 2004
Posts: 823
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

Joined: Jun 13, 2004
Posts: 13
things clearing up now .. thnx a lot
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: do i have to submit all the time
 
Similar Threads
question on html:submit
Calling Java Script function in CSS Styles
click button to clear session
Conditional form validation
how can i map different Actionform class to single Action class