2016-11-14 46 views
0

我只是想找到一個教程,或者如果有人能指出我正確的方向。我正在做一個小學內聯網站點,它將有一個登錄名,但我在圖像上使用了一個usemap,並且該圖像是數字。UseMap將數據插入表單

我如何得到它,所以當我點擊圖片時,它將值插入到文本框中。

回答

0

function setValue(value) { 
 
    document.getElementById('textbox').value = value; 
 
}
<img src="planets.gif" width="145" height="126" alt="Planets" usemap="#planetmap"> 
 

 
<map name="planetmap"> 
 
    <area shape="rect" coords="0,0,82,126" href="javascript:setValue('Sun')" alt="Sun"> 
 
    <area shape="circle" coords="90,58,3" href="javascript:setValue('Mercury')" alt="Mercury"> 
 
    <area shape="circle" coords="124,58,8" href="javascript:setValue('Venus')" alt="Venus"> 
 
</map> 
 

 
<input type="text" id="textbox" />