javascript - Using images / links to switch form select (dropdown) -


i'm building form client , they've requested map of city let visitors visually pick location, , have link city: dropdown/select area of form.

here's clients old, archaic & disgusting website showcasing want done, though, it's terrible. http://www3.telus.net/russellsrubbish/order_form.htm

i looking @ hidden form value change , i'm unsure if pushing in right direction?

if failed explain myself apologize, i'm pretty novice when comes jquery.

to make work make background sprite map , use image maps. use jquery react on clicking 1 of hotspots , change selected index in select box.

---------------------------------------- edit - working example ------------------------------

heres working example made you: example can click 2 regions in netherlands on map, "noord-brabant" , "gelderland".

html:

<div class="mymap">   <img alt="" src="map_overlay.png" usemap="#holland"> </div>  <map id="mymap" name="holland">   <area shape="circle" coords="280,230,30" alt="gelderland" />   <area shape="circle" coords="200,300,30" alt="brabant" /> </map>  <select class="mymapselect">   <option value="none">take pick on map</option>   <option value="brabant">brabant</option>   <option value="gelderland">gelderland</option> </select> 

css:

  .mymap {     background: url('map.png');     width: 393px;     height: 449px;   }    .mymap.brabant {     background-position: -393px 0;   }    .mymap.gelderland {     background-position: -786px 0;   } 

js:

<script type="text/javascript">     $('area', '#mymap').mouseover(function(){       $('.mymap').attr('class', 'mymap ' + $(this).attr('alt'));     });     $('area', '#mymap').mouseout(function(){       $('.mymap').attr('class', 'mymap');     });     $('area', '#mymap').click(function(){       $(".mymapselect").val($(this).attr('alt'));     }); </script> 

so did make sprite background images map. use transparent img can add our image maps , make hovers on area's change class based upon alt attribute. need add styling regions , make sprite move.

hope helps :)


Comments

Popular posts from this blog

linux - Mailx and Gmail nss config dir -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -