JavaScript 동적 생 성 표 열


<script>
var pattern =/\.jpg/i;
var src = '';
var vLink = document.getElementsByName("link");
var imageSrc = document.getElementsByName("imageSrc");
var len = vLink.length;
var tr = document.getElementById('image');//image  ID
var url = '';
//     
for(i=0; i<len; i++){
    url = vLink[i].value;
    src = imageSrc[i].value;
    src = src.substring(0, src.match(pattern).index);
    src = '../images/' + src + '.jpg';
    var td = tr.insertCell(i);
    td.setAttribute("width", "135");
    tdHtml = '<table border=0 width=130 cellpadding=0 cellspacing=0>';
    tdHtml += '<tr><td><a href="';
    tdHtml = tdHtml + url + '">';
    tdHtml += '<img width=130 height=89 src="';
    tdHtml = tdHtml + src+ '"/></a>';
    tdHtml += '</td></tr></table>';
    td.innerHTML = tdHtml;
    //   IE   
    //        
    /*
    var table = document.createElement("table");
    table.setAttribute("width", "130");
    table.setAttribute("cellpadding", "0");
    table.setAttribute("cellspacing", "0");
    var childTr = document.createElement("tr");
    var childTd = document.createElement("td");
    var href = document.createElement("a");
    href.setAttribute("href", url);
    var image = document.createElement("img");
    image.setAttribute("src", content);
    image.setAttribute("width", "130");
    image.setAttribute("height", "89");
    href.appendChild(image);
    childTd.appendChild(href);
    childTr.appendChild(childTd);
    table.appendChild(childTr);
    td.appendChild(table);
    tr.appendChild(td);
    */
}
</script>

좋은 웹페이지 즐겨찾기