2013-03-25 173 views
0

這是我不知道的那些日子之一:我是否會失去主意?如果我通過這個簡單的JavaScript函數步驟,從3行的執行跳到第7行爲什麼JavaScript跳過我的功能?

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"> 
... 

有誰看到我在做什麼錯在這裏?

+6

你在哪裏調用函數? – j08691 2013-03-25 21:12:55

+9

第3行和第7行是什麼? – Blender 2013-03-25 21:13:07

+4

中間有四行空白/評論? – Bergi 2013-03-25 21:13:07

回答

6

看來您正在使用錯誤的索引變量名稱。嘗試使用您定義的那個studyindex。

+0

是的,這是它... – rixter 2013-03-25 21:26:37

1

您尚未定義索引變量。最好使用firebug或chrome的開發工具來調試javascript問題。

+0

賓果!謝謝... – rixter 2013-03-25 21:27:02