HTML/javascript/WebForm: MapArea hotspot to set <input value= >

I have an application where i need to have the result of clicking on a hotspot (area map) within an image,  to do a submit immediately with a unique parameter that identifies which hotspot was clicked on.

Ex:   Image:
|       1     |       2      |
|       3     |       4      |

thus if the picture area around "1" above was clicked on,  a submit would be done with either the submit parameter or an input parameter set to "1"

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

The "hotspot" is typically associated to a url. On the url itself, you need to append the data you want to send. Example: if the <input> was:
<input name="planet" value="" type="hidden"> and it typically gets sent to, then you now need to update the url so that it contains all the information on the link. That way, when the user clicks on the hotspot the browser will send the information directly. As an example your link would need to change to:

Look at the complete example below. I am sending the selections directly to Google.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
<head><base href=""/>
<p>Click on one of the planets:</p>
<img src ="planets.gif"
width ="145" height ="126"
usemap ="#planetmap" />
<map id ="planetmap" name="planetmap">
<area shape ="rect" coords ="0,0,82,126"
  href ="" target ="_blank"
  alt="Sun" />
<area shape ="circle" coords ="90,58,3"
  href ="" target ="_blank"
  alt="Mercury" />
<area shape ="circle" coords ="124,58,8"
  href ="" target ="_blank"
  alt="Venus" />

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Below is another example of a possible solution; in this case javascript is used to set the value of a hidden field and to submit the form:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="" >
    <title>Untitled Page</title>
    <script type="text/javascript">
    // <![CDATA[
    function SetValue(nVal)
        document.getElementById('hidVal').value = nVal;
        alert("Set value of hidden input field to: " + nVal);
    // ]]>
<form name="frmImage" id="frmImage" action="areamap.htm">
<img src="pic.png" usemap="#links" border="0" />
<map name="links">
<area shape="rect" coords="0, 0, 50, 50" href="javascript:SetValue('1');" />
<area shape="rect" coords="50,0,100,50" href="javascript:SetValue('2');" />
<area shape="rect" coords="0,50,50, 100" href="javascript:SetValue('3');" />
<area shape="rect" coords="50, 50, 100, 100" href="javascript:SetValue('4');" />
<input type="hidden" id="hidVal" name="hidVal" />

Open in new window

willsherwoodAuthor Commented:
quick and right on target - thanks to BOTH!!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.