我正在調用一個名爲'capital()'的函數,但它不工作,'人均'正在工作。 它是js中的關鍵字還是這是什麼?在javascript中是否有關鍵字'capital'?
這裏是代碼中看到它,測試它
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>HTML Select Element</title>
<script type="text/javascript">
function capita(){
alert('yes');
c = new Array("Islamabad", "Tehran", "Bejing", "New Delhi", "Kabul");
var i;
i = document.f1.country.selectedIndex;
document.f1.capital.value=c[i];
}
</script>
</head>
<body>
<h3>Countries and Capital</h3>
<form name="f1" method="post">
The capital of
<select name="country" id="country" onChange="capita();">
<option selected>Pakistan
<option>Iran
<option>China
<option>India
<option>Afghanistan
</select>
is <input type="text" name="capital" value="Islamabad"/>
</form>
</body>
</html>
函數被調用上選擇名單的事件onchange – Bilal
**請告訴我們您的代碼**。 – SLaks
你會得到什麼錯誤? – JJJ