文件的script.js,
function AdaugaComboBox(id, name){
var select_tag = document.getElementById(id);
select_tag.innerHTML += "<select name='"+name+"'><option value='0'>Selecteaza autor</option></select><br/>";
return true;
}
和文件index.html的:
<html>
<head>
<script src="js/script.js" type="text/javascript"></script>
</head>
<body>
<table>
<tr>
<td id="autori">...</td>
</tr>
<tr>
<td>
<input type="button"
value="Adauga autor"
onclick="AdaugaComboBox('autori', 'autori[]')"/>
</td>
</tr>
</table>
</body>
</html>
功能的范围是将一个组合框添加到TABLE中的特定TD。但是,当我按下按钮会出现这样的错误:
AdaugaComboBox没有定义
为什么?
更新:
!我修复了它。问题出在另一个功能上。
script.js不包含在HTML中的任何位置...... – Langdon 2010-01-27 12:32:18
在文档树中的哪个位置定义了函数? – 2010-01-27 12:32:49
script.js包含在文档中,我得到相同的错误。 – Emanuel 2010-01-27 12:40:21