0
我正在重寫一個腳本,很多都是從我的原始腳本(根本沒有編碼問題)剪切和粘貼。Uncaught TypeError:無法讀取null的屬性'值'..(在空白行上)
<script type="text/javascript">
function Svdelivery() {
var dataString = "Booking_ID=" + document.getElementById('Booking_ID').value + "&Client_ID=167&DeliveryName=" + document.getElementById('DeliveryName').value + "&DeliveryNumber=" + document.getElementById('DeliveryNumber').value + "&DeliveryAddress=" + document.getElementById('DelAddress').value + "&Instructions=" + Instructions;
alert(dataString);
}
</script>
不管我做什麼,如果我在那裏有一個變種,它總是拋出此錯誤
Uncaught TypeError: Cannot read property 'value' of null
at Svdelivery (index.php?option=com_chronoforms5&chronoform=Booking&event=Delivery:98)
at HTMLInputElement.onclick (index.php?option=com_chronoforms5&chronoform=Booking&event=Delivery:564)
Svdelivery @ index.php?option=com_chronoforms5&chronoform=Booking&event=Delivery:98
onclick @ index.php?option=com_chronoforms5&chronoform=Booking&event=Delivery:564
指向行function Svdelivery() {
或下方的一個空白。我已將代碼剝離,以解決問題,但仍遇到同樣的問題。我也改變了功能名稱,但仍然,沒有...任何想法?
您是否具有上述指定ID的所有元素? – Satpal
你在加載元素後調用Svdelivery()函數嗎? – nnnnnn
不,但我會認爲它會返回「NULL」。但我會嘗試 – Ben