我試圖加載在身體的onload 2 JavaScript事件/功能如下: -身體的onload加載JavaScript與2個功能
<body onLoad="getSubs(document.form1.HotelID.options[document.form1.HotelID.selectedIndex].value);getTags(document.form1.HotelID.options[document.form1.HotelID.selectedIndex].value);">
每當我加載使用2種功能的第一個中止 - 但如果我只是加載一個它工作正常 - 我做錯了什麼是不可能在onload中放2個函數?
你應該真的避免內聯處理程序。他們使你的代碼無法維繫。無論如何,顯然你沒有語法錯誤 – fcalderan 2012-04-12 11:25:42
另請參見:[爲什麼內聯CSS和JavaScript代碼是如此糟糕](http://robertnyman.com/2008/11/20/why-inline-css-and-javascript-code -is-這樣-A-壞事情/)。另外,作爲'document'屬性直接訪問表單是非標準的。將它們作爲document.forms的屬性和元素作爲表單元素屬性的屬性(例如'document.forms.form1.elements.HotelId')或直接由ID(例如'document.getElementById('HotelID' )',假設名爲'HotelID'的輸入也被賦予相同的ID)。 – outis 2012-04-12 11:27:15
不確定它是否有任何區別,但這兩個函數執行AJAX請求。 – 2012-04-12 11:42:45