我的html中有这个
function populate(myop) {
var selection = myop.options[myop.selectedIndex].text;
PopulateTaskddl(selection);
}
<select id="ddljobname_In" name="cpname_job" onchange="populate(this.value)" style="margin-left: 10px; color: Black;">
</select>
它给我错误说“Populate未定义..
任何帮助?
答案 0 :(得分:2)
您必须将JavaScript函数放在脚本标记中,以便浏览器知道它的JavaScript,而不是HTML。
JS不是HTML,您必须声明。您可以从一些教程开始,学习如何使用HTML,CSS,JavaScript和合。在发布像StackOverflow这样的Q&amp; A平台之前。
<script>
function populate(myop) {
var selection = myop.options[myop.selectionIndex].text;
PopulateTaskddl(selection);
}
<script>
<select id="ddljobname_In" name="cpname_job" onchange="populate(this.value)" style="margin-left: 10px; color: Black;">
</select>
答案 1 :(得分:-1)
<select id="ddljobname_In" name="cpname_job" onchange="populate(this)" style="margin-left: 10px; color: Black;">
</select>
<script type="text/javascript">
function populate(myop) {
var selection = myop.options[myop.selectedIndex].text;
PopulateTaskddl(selection);
}
</script>