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?

[Webinar] Streamline your web hosting managementRegister Today

hieloConnect With a Mentor Commented:
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

LordOfPortsConnect With a Mentor Commented:
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!!
All Courses

From novice to tech pro — start learning today.