我想做一個頁面,你輸入一個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>
它是「getElementById()」,小寫「g」。瀏覽器控制檯將包含此錯誤。 – Pointy
這個問題似乎是題外話題,因爲它是關於一個簡單的印刷錯誤。 – Pointy
JSFiddle(雖然看起來已經解決了):http://jsfiddle.net/fw74s/1/ – cardern