Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

How to Find which Image Map Area Clicked

Posted on 2012-08-29
2
Medium Priority
?
359 Views
Last Modified: 2012-08-29
Hi Folks,

I wanted to find out which area has been clicked on the Image map thru Javascript. How do I do that?

I need to evaluate if lets say Validate area has been clicked or not.

 <map name="0110">
    <area shape="rect" coords="14,82,161,388" href="#validate" alt="Validate">
    <area shape="rect" coords="164,80,313,388" href="#request" alt="Request">
    <area shape="rect" coords="316,78,461,394" href="#need" alt="need">

  </map>

if (href="validate"){
 alert("Correct");
}

Open in new window

0
Comment
Question by:rgarimella
2 Comments
 
LVL 7

Assisted Solution

by:dimmergeek
dimmergeek earned 1000 total points
ID: 38347710
<img src="your_img_name.aaa" usemap="#0110" alt="Click your answer"/>

<map name="0110">
    <area shape="rect" coords="14,82,161,388" onclick="setHREF('validate');" alt="Validate">
    <area shape="rect" coords="164,80,313,388" onclick="setHREF('request');" alt="Request">
    <area shape="rect" coords="316,78,461,394" onclick="setHREF('need')" alt="need">
</map>

<script type="text/javascript" language="javascript">
var hrefVal;
function setHREF(value)
{
     hrefVal = value;
     if (hrefVal=="validate")
          alert("Correct");
}
</script>

Open in new window

0
 
LVL 61

Accepted Solution

by:
HainKurt earned 1000 total points
ID: 38347784
or maybe something like this

<img src="your_img_name.gif" usemap="#0110" alt="Click your answer" width=400 height=400/>
<map name="0110">
    <area shape="rect" coords="14,82,161,388" href="#" alt="Validate" onClick="return checkArea('A')">
    <area shape="rect" coords="164,80,313,388" href="#" alt="Request" onClick="return checkArea('B')">
    <area shape="rect" coords="316,78,461,394" href="#" alt="need" onClick="return checkArea('C')">
</map>
<script>
function checkArea(m){
	if (m=="B"){
		alert("Correct.");
	} else {
		alert("Not Correct!");
	} 
	return false;
}
</script>

Open in new window

0

Featured Post

[Webinar] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

578 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question