2016-09-24 115 views
-1

我仍然是一個noob在這...我倒了這個代碼片段,無法找到我的錯誤。我知道textareaREMARKSTEXTAREA被省略,因爲我不覺得它是相關的。基本上,這是我正在開發的用於創建高端數據電路測試的工具。爲什麼選擇選項後該功能不會觸發?

<!-- BEGIN TEST PATTERNS DROPDOWN MENU --> 
 
<td style="text-align: center; width: 638px;"> 
 
    <select id="testingdropdownmenu"> 
 
    <option value="">MAKE A SELECTION</option> 
 
    <option value="1">RAN QRSS TEST PATTERN FOR X MINUTES AND TESTING OKAY…</option> 
 
    <option value=" RAN QRSS TEST PATTERN FOR 3 MINUTES AND TESTING OKAY… ">RAN QRSS TEST PATTERN FOR 3 MINUTES AND TESTING OKAY…</option> 
 
    <option value=" RAN QRSS TEST PATTERN FOR 15 MINUTES AND TESTING OKAY… ">RAN QRSS TEST PATTERN FOR 15 MINUTES AND TESTING OKAY…</option> 
 
    <option value=" RAN QRSS TEST PATTERN AND FINDING ERRORS…">RAN QRSS TEST PATTERN AND FINDING ERRORS…</option> 
 
    <option value="2">RAN ALL ZEROES TEST PATTERN FOR X SECONDS AND TESTING OKAY…</option> 
 
    <option value=" RAN ALL ZEROES TEST PATTERN FOR 30 SECONDS AND TESTING OKAY… ">RAN ALL ZEROES TEST PATTERN FOR 30 SECONDS AND TESTING OKAY…</option> 
 
    <option value=" RAN ALL ZEROES TEST PATTERN AND FINDING ERRORS…">RAN ALL ZEROES TEST PATTERN AND FINDING ERRORS…</option> 
 
    <option value="3">RAN T-DALY TEST PATTERN FOR X MINUTES AND TESTING OKAY…</option> 
 
    <option value=" RAN T-DALY TEST PATTERN AND FINDING ERRORS…">RAN T-DALY TEST PATTERN AND FINDING ERRORS…</option> 
 
    <option value="4">RAN 1:8 TEST PATTERN FOR X MINUTES AND TESTING OKAY…</option> 
 
    <option value=" RAN 1:8 TEST PATTERN FOR 5 MINUTES AND TESTING OKAY… ">RAN 1:8 TEST PATTERN FOR 5 MINUTES AND TESTING OKAY…</option> 
 
    <option value=" RAN 1:8 TEST PATTERN AND FINDING ERRORS…">RAN 1:8 TEST PATTERN AND FINDING ERRORS…</option> 
 
    <option value="5">RAN 1:7 TEST PATTERN FOR X MINUTES AND TESTING OKAY…</option> 
 
    <option value=" RAN 1:7 TEST PATTERN FOR 5 MINUTES AND TESTING OKAY… ">RAN 1:7 TEST PATTERN FOR 5 MINUTES AND TESTING OKAY…</option> 
 
    <option value=" RAN 1:7 TEST PATTERN AND FINDING ERRORS…">RAN 1:7 TEST PATTERN AND FINDING ERRORS…</option> 
 
    <option value="6">RAN 2-IN-8 TEST PATTERN FOR X MINUTES AND TESTING OKAY…</option> 
 
    <option value=" RAN 2-IN-8 TEST PATTERN AND FINDING ERRORS…">RAN 2-IN-8 TEST PATTERN AND FINDING ERRORS…</option> 
 
    <option value="7">RAN BRIDGETAP TEST PATTERN FOR X MINUTES AND TESTING OKAY…</option> 
 
    <option value=" RAN BRIDGETAP TEST PATTERN AND FINDING ERRORS…">RAN BRIDGETAP TEST PATTERN AND FINDING ERRORS…</option> 
 
    <option value="8">RAN ALL ONES TEST PATTERN FOR X MINUTES AND TESTING OKAY…</option> 
 
    <option value=" RAN ALL ONES TEST PATTERN FOR 5 MINUTES AND TESTING OKAY… ">RAN ALL ONES TEST PATTERN FOR 5 MINUTES AND TESTING OKAY…</option> 
 
    <option value=" RAN ALL ONES TEST PATTERN AND FINDING ERRORS…">RAN ALL ONES TEST PATTERN AND FINDING ERRORS…</option> 
 
    <option value=" RAN 3-IN-24 TEST PATTERN FOR 5 MINUTES AND TESTING OKAY… ">RAN 3-IN-24 TEST PATTERN FOR 5 MINUTES AND TESTING OKAY…</option> 
 
    <option value=" RAN 3-IN-24 TEST PATTERN AND FINDING ERRORS…">RAN 3-IN-24 TEST PATTERN AND FINDING ERRORS…</option> 
 
    <option value=" RAN MULTIPAT TEST PATTERN FOR 5 MINUTES AND TESTING OKAY… ">RAN MULTIPAT TEST PATTERN FOR 5 MINUTES AND TESTING OKAY…</option> 
 
    <option value=" RAN MULTIPAT TEST PATTERN AND FINDING ERRORS…">RAN MULTIPAT TEST PATTERN AND FINDING ERRORS…</option> 
 
    </select> 
 
    <script> 
 
    var mytextbox = document.getElementById('REMARKSTEXTAREA'); 
 
    var mydropdown = document.getElementById('testingdropdownmenu'); 
 
    mydropdown.onchange = function() if (mydropdown != null) { 
 
     if (mydropdown.value == 1) { 
 
     var TIME = prompt("HOW MANY MINUTES DID YOU RUN THE TEST PATTERN FOR?"); 
 
     mytextbox.value = mytextbox.value + " RAN QRSS TEST PATTERN FOR " + TIME + "MINUTES AND TESTING OKAY..."; 
 
     this.value = ""; 
 
     } else if (mydropdown.value == 2) { 
 
     var TIME = prompt("HOW MANY SECONDS DID YOU RUN THE TEST PATTERN FOR?"); 
 
     mytextbox.value = mytextbox.value + " RAN ALL ZEROES TEST PATTERN FOR " + TIME + " SECONDS AND TESTING OKAY…"; 
 
     this.value = ""; 
 
     } else if (mydropdown.value == 3) { 
 
     var TIME = prompt("HOW MANY MINUTES DID YOU RUN THE TEST PATTERN FOR?"); 
 
     mytextbox.value = mytextbox.value + " RAN T-DALY TEST PATTERN FOR " + TIME + " MINUTES AND TESTING OKAY…"; 
 
     this.value = ""; 
 
     } else if (mydropdown.value == 4) { 
 
     var TIME = prompt("HOW MANY MINUTES DID YOU RUN THE TEST PATTERN FOR?"); 
 
     mytextbox.value = mytextbox.value + " RAN 1:8 TEST PATTERN FOR " + TIME + " MINUTES AND TESTING OKAY…"; 
 
     this.value = ""; 
 
     } else if (mydropdown.value == 5) { 
 
     var TIME = prompt("HOW MANY MINUTES DID YOU RUN THE TEST PATTERN FOR?"); 
 
     mytextbox.value = mytextbox.value + " RAN 1:7 TEST PATTERN FOR " + TIME + " MINUTES AND TESTING OKAY…"; 
 
     this.value = ""; 
 
     } else if (mydropdown.value == 6) { 
 
     var TIME = prompt("HOW MANY MINUTES DID YOU RUN THE TEST PATTERN FOR?"); 
 
     mytextbox.value = mytextbox.value + " RAN 2-IN-8 TEST PATTERN FOR " + TIME + " MINUTES AND TESTING OKAY…"; 
 
     this.value = ""; 
 
     } else if (mydropdown.value == 7) { 
 
     var TIME = prompt("HOW MANY MINUTES DID YOU RUN THE TEST PATTERN FOR?"); 
 
     mytextbox.value = mytextbox.value + " RAN BRIDGETAP TEST PATTERN FOR " + TIME + " MINUTES AND TESTING OKAY…"; 
 
     this.value = ""; 
 
     } else if (mydropdown.value == 8) { 
 
     var TIME = prompt("HOW MANY MINUTES DID YOU RUN THE TEST PATTERN FOR?"); 
 
     mytextbox.value = mytextbox.value + " RAN ALL ONES TEST PATTERN FOR " + TIME + " MINUTES AND TESTING OKAY…"; 
 
     this.value = ""; 
 
     } else { 
 
     mytextbox.value = mytextbox.value + " " + mydropdown + "..."; 
 
     this.value = ""; 
 
     } 
 
    } 
 
    } 
 
    } 
 
    </script> 
 
</td> 
 
<!-- END TESTING PATTERNS MENU -->

+1

檢查你的開發人員工具控制檯錯誤 –

+0

語法錯誤附近'()的函數,如果(mydropdown!= NULL){'。檢查您的控制檯的細節。 – techfoobar

+0

^我建議通過控制檯查看,然後你會看到大量的錯誤被提出。 – Li357

回答

1

你的if語句打開和關閉括號不匹配。

用附加的代碼替換腳本代碼,它應該工作正常。

 <script> 
var mytextbox = document.getElementById('REMARKSTEXTAREA'); 
var mydropdown = document.getElementById('testingdropdownmenu'); 
mydropdown.onchange = function(){if (mydropdown != null) { 
if (mydropdown.value == 1) { 
var TIME = prompt("HOW MANY MINUTES DID YOU RUN THE TEST PATTERN FOR?"); mytextbox.value = mytextbox.value + " RAN QRSS TEST PATTERN FOR " + TIME + "MINUTES AND TESTING OKAY..."; this.value = "";} 
else if (mydropdown.value == 2) { 
var TIME = prompt("HOW MANY SECONDS DID YOU RUN THE TEST PATTERN FOR?"); mytextbox.value = mytextbox.value + " RAN ALL ZEROES TEST PATTERN FOR " + TIME + " SECONDS AND TESTING OKAY…"; this.value = "";} 
else if (mydropdown.value == 3) { 
var TIME = prompt("HOW MANY MINUTES DID YOU RUN THE TEST PATTERN FOR?"); mytextbox.value = mytextbox.value + " RAN T-DALY TEST PATTERN FOR " + TIME + " MINUTES AND TESTING OKAY…"; this.value = "";} 
else if (mydropdown.value == 4) { 
var TIME = prompt("HOW MANY MINUTES DID YOU RUN THE TEST PATTERN FOR?"); mytextbox.value = mytextbox.value + " RAN 1:8 TEST PATTERN FOR " + TIME + " MINUTES AND TESTING OKAY…"; this.value = "";} 
else if (mydropdown.value == 5) { 
var TIME = prompt("HOW MANY MINUTES DID YOU RUN THE TEST PATTERN FOR?"); mytextbox.value = mytextbox.value + " RAN 1:7 TEST PATTERN FOR " + TIME + " MINUTES AND TESTING OKAY…"; this.value = "";} 
else if (mydropdown.value == 6) { 
var TIME = prompt("HOW MANY MINUTES DID YOU RUN THE TEST PATTERN FOR?"); mytextbox.value = mytextbox.value + " RAN 2-IN-8 TEST PATTERN FOR " + TIME + " MINUTES AND TESTING OKAY…"; this.value = "";} 
else if (mydropdown.value == 7) { 
var TIME = prompt("HOW MANY MINUTES DID YOU RUN THE TEST PATTERN FOR?"); mytextbox.value = mytextbox.value + " RAN BRIDGETAP TEST PATTERN FOR " + TIME + " MINUTES AND TESTING OKAY…"; this.value = "";} 
else if (mydropdown.value == 8) { 
var TIME = prompt("HOW MANY MINUTES DID YOU RUN THE TEST PATTERN FOR?"); mytextbox.value = mytextbox.value + " RAN ALL ONES TEST PATTERN FOR " + TIME + " MINUTES AND TESTING OKAY…"; this.value = "";} 
else { 
mytextbox.value = mytextbox.value + " " + mydropdown + "..."; this.value = "";} 
} 
} 

     </script> 
+0

當我運行「[object HTMLSelectElement] ...」時,我一直在textarea中獲得followig ...「......任何線索? –

+0

請提供完整的頁面源代碼,以便於調試, –

0

var mytextbox = document.getElementById('REMARKSTEXTAREA'); 
 
var mydropdown = document.getElementById('testingdropdownmenu'); 
 
mydropdown.onchange = function(){if (mydropdown != null) { 
 
if (mydropdown.value == 1) { 
 
var TIME = prompt("HOW MANY MINUTES DID YOU RUN THE TEST PATTERN FOR?"); mytextbox.value = mytextbox.value + " RAN QRSS TEST PATTERN FOR " + TIME + "MINUTES AND TESTING OKAY..."; this.value = "";} 
 
else if (mydropdown.value == 2) { 
 
var TIME = prompt("HOW MANY SECONDS DID YOU RUN THE TEST PATTERN FOR?"); mytextbox.value = mytextbox.value + " RAN ALL ZEROES TEST PATTERN FOR " + TIME + " SECONDS AND TESTING OKAY…"; this.value = "";} 
 
else if (mydropdown.value == 3) { 
 
var TIME = prompt("HOW MANY MINUTES DID YOU RUN THE TEST PATTERN FOR?"); mytextbox.value = mytextbox.value + " RAN T-DALY TEST PATTERN FOR " + TIME + " MINUTES AND TESTING OKAY…"; this.value = "";} 
 
else if (mydropdown.value == 4) { 
 
var TIME = prompt("HOW MANY MINUTES DID YOU RUN THE TEST PATTERN FOR?"); mytextbox.value = mytextbox.value + " RAN 1:8 TEST PATTERN FOR " + TIME + " MINUTES AND TESTING OKAY…"; this.value = "";} 
 
else if (mydropdown.value == 5) { 
 
var TIME = prompt("HOW MANY MINUTES DID YOU RUN THE TEST PATTERN FOR?"); mytextbox.value = mytextbox.value + " RAN 1:7 TEST PATTERN FOR " + TIME + " MINUTES AND TESTING OKAY…"; this.value = "";} 
 
else if (mydropdown.value == 6) { 
 
var TIME = prompt("HOW MANY MINUTES DID YOU RUN THE TEST PATTERN FOR?"); mytextbox.value = mytextbox.value + " RAN 2-IN-8 TEST PATTERN FOR " + TIME + " MINUTES AND TESTING OKAY…"; this.value = "";} 
 
else if (mydropdown.value == 7) { 
 
var TIME = prompt("HOW MANY MINUTES DID YOU RUN THE TEST PATTERN FOR?"); mytextbox.value = mytextbox.value + " RAN BRIDGETAP TEST PATTERN FOR " + TIME + " MINUTES AND TESTING OKAY…"; this.value = "";} 
 
else if (mydropdown.value == 8) { 
 
var TIME = prompt("HOW MANY MINUTES DID YOU RUN THE TEST PATTERN FOR?"); mytextbox.value = mytextbox.value + " RAN ALL ONES TEST PATTERN FOR " + TIME + " MINUTES AND TESTING OKAY…"; this.value = "";} 
 
else { 
 
mytextbox.value = mytextbox.value + " " + mydropdown + "..."; this.value = "";} 
 
} 
 
}
<!-- BEGIN TEST PATTERNS DROPDOWN MENU --> 
 
<td style="text-align: center; width: 638px;"> 
 
    <select id="testingdropdownmenu"> 
 
    <option value="">MAKE A SELECTION</option> 
 
    <option value="1">RAN QRSS TEST PATTERN FOR X MINUTES AND TESTING OKAY…</option> 
 
    <option value=" RAN QRSS TEST PATTERN FOR 3 MINUTES AND TESTING OKAY… ">RAN QRSS TEST PATTERN FOR 3 MINUTES AND TESTING OKAY…</option> 
 
    <option value=" RAN QRSS TEST PATTERN FOR 15 MINUTES AND TESTING OKAY… ">RAN QRSS TEST PATTERN FOR 15 MINUTES AND TESTING OKAY…</option> 
 
    <option value=" RAN QRSS TEST PATTERN AND FINDING ERRORS…">RAN QRSS TEST PATTERN AND FINDING ERRORS…</option> 
 
    <option value="2">RAN ALL ZEROES TEST PATTERN FOR X SECONDS AND TESTING OKAY…</option> 
 
    <option value=" RAN ALL ZEROES TEST PATTERN FOR 30 SECONDS AND TESTING OKAY… ">RAN ALL ZEROES TEST PATTERN FOR 30 SECONDS AND TESTING OKAY…</option> 
 
    <option value=" RAN ALL ZEROES TEST PATTERN AND FINDING ERRORS…">RAN ALL ZEROES TEST PATTERN AND FINDING ERRORS…</option> 
 
    <option value="3">RAN T-DALY TEST PATTERN FOR X MINUTES AND TESTING OKAY…</option> 
 
    <option value=" RAN T-DALY TEST PATTERN AND FINDING ERRORS…">RAN T-DALY TEST PATTERN AND FINDING ERRORS…</option> 
 
    <option value="4">RAN 1:8 TEST PATTERN FOR X MINUTES AND TESTING OKAY…</option> 
 
    <option value=" RAN 1:8 TEST PATTERN FOR 5 MINUTES AND TESTING OKAY… ">RAN 1:8 TEST PATTERN FOR 5 MINUTES AND TESTING OKAY…</option> 
 
    <option value=" RAN 1:8 TEST PATTERN AND FINDING ERRORS…">RAN 1:8 TEST PATTERN AND FINDING ERRORS…</option> 
 
    <option value="5">RAN 1:7 TEST PATTERN FOR X MINUTES AND TESTING OKAY…</option> 
 
    <option value=" RAN 1:7 TEST PATTERN FOR 5 MINUTES AND TESTING OKAY… ">RAN 1:7 TEST PATTERN FOR 5 MINUTES AND TESTING OKAY…</option> 
 
    <option value=" RAN 1:7 TEST PATTERN AND FINDING ERRORS…">RAN 1:7 TEST PATTERN AND FINDING ERRORS…</option> 
 
    <option value="6">RAN 2-IN-8 TEST PATTERN FOR X MINUTES AND TESTING OKAY…</option> 
 
    <option value=" RAN 2-IN-8 TEST PATTERN AND FINDING ERRORS…">RAN 2-IN-8 TEST PATTERN AND FINDING ERRORS…</option> 
 
    <option value="7">RAN BRIDGETAP TEST PATTERN FOR X MINUTES AND TESTING OKAY…</option> 
 
    <option value=" RAN BRIDGETAP TEST PATTERN AND FINDING ERRORS…">RAN BRIDGETAP TEST PATTERN AND FINDING ERRORS…</option> 
 
    <option value="8">RAN ALL ONES TEST PATTERN FOR X MINUTES AND TESTING OKAY…</option> 
 
    <option value=" RAN ALL ONES TEST PATTERN FOR 5 MINUTES AND TESTING OKAY… ">RAN ALL ONES TEST PATTERN FOR 5 MINUTES AND TESTING OKAY…</option> 
 
    <option value=" RAN ALL ONES TEST PATTERN AND FINDING ERRORS…">RAN ALL ONES TEST PATTERN AND FINDING ERRORS…</option> 
 
    <option value=" RAN 3-IN-24 TEST PATTERN FOR 5 MINUTES AND TESTING OKAY… ">RAN 3-IN-24 TEST PATTERN FOR 5 MINUTES AND TESTING OKAY…</option> 
 
    <option value=" RAN 3-IN-24 TEST PATTERN AND FINDING ERRORS…">RAN 3-IN-24 TEST PATTERN AND FINDING ERRORS…</option> 
 
    <option value=" RAN MULTIPAT TEST PATTERN FOR 5 MINUTES AND TESTING OKAY… ">RAN MULTIPAT TEST PATTERN FOR 5 MINUTES AND TESTING OKAY…</option> 
 
    <option value=" RAN MULTIPAT TEST PATTERN AND FINDING ERRORS…">RAN MULTIPAT TEST PATTERN AND FINDING ERRORS…</option> 
 
    </select> 
 
</td> 
 

+0

感謝球員們......我能夠在你的幫助下完成工作。非常感激!!!! –

相關問題