34
Chapter 1
The JavaScript’s ready, and the button no longer tries to submit
the form... but right now, getBoardsSold() never runs, either.
This shouldn’t be too hard to x, though:
Running getBoardsSold() from the web form
Can’t we just run the
getBoardsSold() function
whenever someone clicks on
“Show Me the Money”?
<input value=”Show Me the Money” type=”button” />
function getBoardsSold() { ... }
Any time this button is clicked...
...this JavaScript function
needs to get called.
A Question For JavaScript
JavaScript, we need to run a function from our HTML. Can you help us out?
Oh, well I’m incredibly exible when it comes to calling functions from a
web page. Just use one of my event handlers in your HTML. You can use
onBlur() for when someone leaves a eld, or onClick(), for when a
user clicks... how about onChange(), for when a value changes... or there’s
onFocus()... wait, wait, I’ve got more... what do you mean, out of time?
avoiding form submits