• 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
  • Ron McLeod
  • Tim Cooke
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Jeanne Boyarsky
Saloon Keepers:
  • Stephan van Hulst
  • Carey Brown
  • Tim Holloway
  • Piet Souris
Bartenders:

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: 67699
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.
 
Talk sense to a fool and he calls you foolish. -Euripides A foolish tiny ad:
The Low Tech Laboratory Movie Kickstarter is LIVE NOW!
https://www.kickstarter.com/projects/paulwheaton/low-tech
reply
    Bookmark Topic Watch Topic
  • New Topic