• 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

Generic function assignment

 
Ranch Hand
Posts: 838
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,
I have a function that, upon window load, goes through a page and assign functions to the onclick events of some form elements (esp. buttons). Is there a way to mimic the following by assignment through javascript?


In my case the html code would not have the onclick section but in a function on load it would grab the submitButton and assign a function. How do I "return false" in this case? Thanks.

Rob
 
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why does the control have a name rather than an id? Is the value of the button significant on the server? If not, no name.

Names are for the server, ids are for the client.

Assuming that we change the attribute to id="submitButton":


P.S. When embedding handlers in HTML markup (not recommended) do not use the javascript: prefix.
 
Rob Hunter
Ranch Hand
Posts: 838
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Bear, I didn't copy and paste but the actual code does use id. I found what I was looking for event.returnValue = false. Thanks for the response.
 
reply
    Bookmark Topic Watch Topic
  • New Topic