2013-10-15 20 views
0

我想做一个页面,你输入一个3位数的数字,并基于该数字按钮的onclick将返回一个不同的图像(地图以显示号码所在的位置)基于其他if语句。我被卡在按钮上 - 点击时不会显示任何内容,甚至是错误信息。任何想法它有什么问题吗?我是一名虚拟初学者,所以请清楚并体贴你的答案:)谢谢!无法让我的onclick显示任何东西(使用其他系统)

<html> 
<head> 
<script> 
function SearchMap() 
var dewey; 
dewey= parseFloat(document.getElementById('search1').value); 

if (dewey >= 000 && 099 >= dewey) 
    { 
    document.GetElementById('image1').src='http://marengo.info-science.uiowa.edu/foundations/maps/A.png'; 
    document.GetElementById('caption1').innerHTML='You want to go to the fourth floor. Your item is in the Generalities section.' 
    } 
else if (dewey >= 100 && 199 >= dewey) 
    { 
    document.GetElementById('image1').src='http://marengo.info-science.uiowa.edu/foundations/maps/B.png'; 
    document.GetElementById('caption1').innerHTML='You want to go to the fourth floor. Your item is in the Philosophy and Psychology section.' 
    } 
else if (dewey >= 200 && 299 >= dewey) 
    { 
    document.GetElementById('image1').src='http://marengo.info-science.uiowa.edu/foundations/maps/C.png'; 
    document.GetElementById('caption1').innerHTML='You want to go to the third floor. Your item is in the Religion section.' 
    } 
else if (dewey >= 300 && 399 >= dewey) 
    { 
    document.GetElementById('image1').src='http://marengo.info-science.uiowa.edu/foundations/maps/D.png'; 
    document.GetElementById('caption1').innerHTML='You want to go to the third floor. Your item is in the Social Sciences section.' 
    } 
else if (dewey >= 400 && 499 >= dewey) 
    { 
    document.GetElementById('image1').src='http://marengo.info-science.uiowa.edu/foundations/maps/E.png'; 
    document.GetElementById('caption1').innerHTML='You want to go to the third floor. Your item is in the Language section.' 
    } 
else if (dewey >= 500 && 599 >= dewey) 
    { 
    document.GetElementById('image1').src='http://marengo.info-science.uiowa.edu/foundations/maps/F.png'; 
    document.GetElementById('caption1').innerHTML='You want to go to the third floor. Your item is in the Natural Sciences and Math section.' 
    } 
else if (dewey >= 600 && 699 >= dewey) 
    { 
    document.GetElementById('image1').src='http://marengo.info-science.uiowa.edu/foundations/maps/G.png'; 
    document.GetElementById('caption1').innerHTML='You want to go to the third floor. Your item is in the Technology section.' 
    } 
else if (dewey >= 700 && 799 >= dewey) 
    { 
    document.GetElementById('image1').src='http://marengo.info-science.uiowa.edu/foundations/maps/H.png'; 
    document.GetElementById('caption1').innerHTML='You want to go to the second floor. Your item is in the Arts section.' 
    } 
else if (dewey >= 800 && 899 >= dewey) 
    { 
    document.GetElementById('image1').src='http://marengo.info-science.uiowa.edu/foundations/maps/I.png'; 
    document.GetElementById('caption1').innerHTML='You want to go to the first floor. Your item is in the Literature and Rhetoric section.' 
    } 
else if (dewey >= 900 && 999 >= dewey) 
    { 
    document.GetElementById('image1').src='http://marengo.info-science.uiowa.edu/foundations/maps/J.png'; 
    document.GetElementById('caption1').innerHTML='You want to go to the second floor. Your item is in the Geography and History section.' 
    } 
else (dewey < 000 || 999 < dewey) 
    { 
    alert=('Your number is outside the Dewey Decimal Range. Please call 319-335-5299 or email [email protected] for assistance.'); 
    } 
</script> 
</head> 
<body> 
<h1 align="center"> 
<img src="http://semanticweb.com/files/2011/04/UIowa.gif"> 
<br> 
<font color="#B18904">University of Iowa Libraries 
</h1> 
<h2 align="center"> 
Search the library floorplan by Dewey Decimal number. </font> 
</h2> 
<p align="center"> 
Type 3-digit Dewey classification number here: <input type="text" id="search1" size=5 value="";> 
</p>  
<p align="center"> 
<input type="button" id="button1" value="Take me there" 
onclick="SearchMap()";> 
</p> 
<p align="center"> 
<img src="" id="image1"> 
<div id='caption1'></div> 
</p> 
</body> 
</html> 
+0

它是“getElementById()”,小写“g”。浏览器控制台将包含此错误。 – Pointy

+1

这个问题似乎是题外话题,因为它是关于一个简单的印刷错误。 – Pointy

+0

JSFiddle(虽然看起来已经解决了):http://jsfiddle.net/fw74s/1/ – cardern

回答

1

你忘了报表附上给你的函数,语法应该看起来更像这个有点:

function SearchMap() 
{ // HERE 
var dewey; 
dewey= parseFloat(document.getElementById('search1').value); 

if (dewey >= 000 && 099 >= dewey) 
    { 
    document.getElementById('image1').src='http://marengo.info-science.uiowa.edu/foundations/maps/A.png'; 
    document.getElementById('caption1').innerHTML='You want to go to the fourth floor. Your item is in the Generalities section.' 
    } 

    etc. 
} // AND HERE 

,当然还有的getElementById的情况。如果您遇到代码问题,您可以始终使用chrome开发控制台和jsfiddle.net来帮助您:)大多数情况下,错误消息非常清晰。

+0

谢谢!我不知道G的国会大厦化问题。同样{}的东西非常有帮助 - 它现在起作用了!谢谢!!! – user2884447

相关问题