- Three options to link javascript to a button
- buttons have associated events you can use
<input type="button" name="submit"
value="submit" onClick="return checkForm()">
- forms have associated events
<Form id="form1" name="form1"
onSubmit = "return checkForm()" METHOD=POST
ACTION="somepage.asp">
<input type="text" name="fullName" size=55>
</form>
- **You can have the script inline - right there on the link in the html
page
<Form id="form1" name="form1"
METHOD=POST ACTION="somepage.asp">
<input type="text" name="fullName" size=55>
<input type="button" name="submit"
value="submit" onClick='if ( fullName =
"" ){alert("Please enter your name");return false;}'>
</form>
- Three options to link javascript to text or an image
- Using events on text or an image
<a href="#" onMouseOver = "swaptwoLayers('clickPop','dollsLayer'
)" > Click here</a>
- Javascript reference inside the href link
<a href="javascript:openWindow()" >Click
here</a>
- **Put the script inline -- right there
<a href="#" onMouseOver = "document.images['homeButton'].src='dim.gif'"
> Click here</a>
**on these two bottom examples -- note the nested
quotes - single quotes inside, double quotes outside it doesn't matter if
you use single quotes outside, but then you must use double quotes inside