Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

controlling a checkbox from an image map

Status
Not open for further replies.

aamaker

Programmer
Jan 20, 2002
222
US
I have an image map that I want to be able to allow the user to click 1 of 8 regions to automatically toggle the corresponding form 'check boxes' that are displayed next to the image.

How would the javascript for something like that look? Anyone familiar with any tutorials on anything like this?

Thanks
 
Give each area an "onclick" event that calls a function with the name of the checkbox you want to toggle:

Code:
<area ... onclick="toggleCheckbox('check01');" ...>

and then add this function to your script section:

Code:
function toggleCheckbox(whichOne) {
   var frm = document.forms['yourFormName'].elements;
   frm[whichOne].checked = !frm[whichOne].checked;
}

Hope this helps,
Dan

Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Really slick -- and easier than I thought.

Many thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top