File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes HTML, CSS and JavaScript and the fly likes input type=image with JS Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "input type=image with JS" Watch "input type=image with JS" New topic
Author

input type=image with JS

Dan Drillich
Ranch Hand

Joined: Jul 09, 2001
Posts: 1168
My submit button is of input type and has a JS function in the onClick attribute.
The JS function submits the form when the function returns true, otherwise, the form is not submitted.
When I replace this button with an image the form is submitted even when the function returns false.
Any ideas?
Thanks,
Dan


William Butler Yeats: All life is a preparation for something that probably will never happen. Unless you make it happen.
Dan Drillich
Ranch Hand

Joined: Jul 09, 2001
Posts: 1168
Here are the code segments -
Works -

Doesn’t work -
Dan Drillich
Ranch Hand

Joined: Jul 09, 2001
Posts: 1168
The dash in the on-Click was forced upon me by the Javaranch HTML disabler ;-(
Randall Twede
Ranch Hand

Joined: Oct 21, 2000
Posts: 4340
    
    2

perhaps the problem is in the function


SCJP
Visit my download page
Dan Drillich
Ranch Hand

Joined: Jul 09, 2001
Posts: 1168
The solution is -

Thanks,
Dan
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: input type=image with JS
 
Similar Threads
Strange - Page Submits!!!
How to submit form with return
from is getting submitted when 'Refresh' button is clicked
form is getting submitted when 'Refresh' button on the browser is clicked.
Limit on Data/Key-Value Pairs in Form Submission