[問題] 請問這段想要動態產生表格的code有問題嗎?

看板Web_Design作者 (ROLL)時間16年前 (2010/01/03 21:39), 編輯推噓4(403)
留言7則, 5人參與, 最新討論串1/1
var tr = document.createElement("tr"); var td1 = document.createElement("td"); var td2 = document.createElement("td"); var td3 = document.createElement("td"); var input1 = document.createElement("textarea"); var input2 = document.createElement("textarea"); var hint_id = document.createElement("input"); var spam = document.createElement("span"); var count = 0; input1.setAttribute("name","hint[]"); input1.setAttribute("cols",17); input1.setAttribute("rows",3); input2.setAttribute("name","content[]"); input2.setAttribute("cols",58); input2.setAttribute("rows",3); hint_id.setAttribute("name","hint_id[]"); hint_id.setAttribute("id","hint_id[]"); hint_id.setAttribute("type","hidden"); try{ count = document.getElementsByName("hint_id[]").length; }catch(e){ count = totalCount; } hint_id.setAttribute("value",document.getElementById("mrid").value+"_"+count); spam.setAttribute("class","funcText"); spam.setAttribute("name","spamTag"); spam.setAttribute("id",count); spam.setAttribute("onclick","spamClick(this,event)"); spam.innerHTML = "請點選"; td1.appendChild(input1); td1.appendChild(hint_id); td2.appendChild(input2); td3.appendChild(spam); tr.appendChild(td1); tr.appendChild(td2); tr.appendChild(td3); document.getElementById("mrform_table").appendChild(tr); totalCount++; 我是透過一個按鈕,按了之後call這個function 但是..firefox可以,ie8也可以, 但是ie7和kkman都不行... 但是我找不到哪一個是ie7不支援的... 先謝謝大家了 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 115.43.123.6

01/03 21:46, , 1F
spam又出現了
01/03 21:46, 1F

01/03 22:00, , 2F
錯誤在哪? spamClick的內容又是啥?
01/03 22:00, 2F

01/03 22:25, , 3F
不要再用spam了...... 上一篇說過,這篇還不改
01/03 22:25, 3F

01/03 22:28, , 4F
不建議用html tag當作名字...
01/03 22:28, 4F

01/03 23:41, , 5F
spam只是變數名稱..因為上一篇~~我有改成span~
01/03 23:41, 5F

01/03 23:42, , 6F
在宣告的時候有改成span~只是後面是變數名稱~我就沒改了
01/03 23:42, 6F

01/04 00:06, , 7F
那個,IE6可能也不會出來,你少了tbody
01/04 00:06, 7F
文章代碼(AID): #1BG9u11A (Web_Design)