• 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

input image and JavaScript

 
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello everybody:

I'd like to replace default HTML buttons for my own buttons using images.



When the user clicks on the image - on_Click="fechaHoy()" -, the script fechaHoy() is supposed to be run but it doesn't work. The script functions perfectly using input type=button. Mozilla Firefox displays the new txtFechaHoy value for instants but immediately disappears. IE doesn't display anything...it seems to me that the page refeshes when click on the button!

Here is the javascript function:


Thanks for your help!

P.D.: English isn't my mother tongue!
[ December 18, 2007: Message edited by: Enrique Villamizar ]
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
To keep the page from posting back you need to cancel the click. You can cancel the click by adding return false to the end.



Eric
 
Enrique Villamizar
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you very much Eric!

That's the difference between someone who knows and someone who doesn't.
I'll promise not to forget that when you clic on a form image it will cause the form to respond as thought the form's Submit button was pressed. Well, I didn't know that!

Just another question: Why the location on the image where the mouse was clicked is sent as part of the form's information. I mean, what could be the practical use of this information?
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic