0

这是我想知道的那些日子之一:我疯了吗?如果我单步执行这个简单的 javascript 函数,执行会从第 3 行跳到第 7 行。

function editStudy() { 
        var studyindex = document.StudyMaint.StudyList.selectedIndex;
        var studyabrv = document.StudyMaint.StudyList[index].text;  //Line 3
        var msg="Edit study "+studyabrv+"?";

        // Get the Study record id was selected in the picklist,
        // then go to Study edit screen, then

        if (confirm(msg)) {
            location.href="editStudy.php?action=UPDATE&studyindex="+studyindex+"&studyabrv="+studyabrv;
        }  //Line 7
    }

但我的表格 StudyMaint 被定义:

<body>
    <?php showUserLine(); ?>
    <form name="StudyMaint" action="Process_StudyMaint.php" method="POST" onsubmit="return false">
    <div id="dataentrybox"> 
        <div id="innerbox">
            <div align="center">
...

有人看到我在这里做错了吗?

4

2 回答 2

6

您似乎使用了错误的索引变量名称。尝试使用您定义的 studyindex。

于 2013-03-25T21:15:22.440 回答
1

您尚未定义索引变量。最好使用 firebug 或 chrome 的开发者工具来调试 javascript 问题。

于 2013-03-25T21:18:59.460 回答