2010-06-22 6 views

Répondre

0

J'ai créé un exemple très simpliste. Vous pouvez le modifier pour adapter votre situation.

<html> 

    <head> 

    <title></title> 

    <script type="text/javascript"> 

    window.onload = function(){ 

    var button = document.getElementById('row_check'); 

    var tableDiv = document.getElementById('container'); 

    var tableHTML = "<div id='mytable'><div id='row_one'>I am not empty</div><div id='row_two'></div><div id='row_three'></div></div>" 

    tableDiv.innerHTML = tableHTML; 

    button.onclick = function(){ 

    if(document.getElementById('row_one').innerHTML == '') alert('Row 1 empty'); 

    if(document.getElementById('row_two').innerHTML == '') alert('Row 2 empty'); 

    if(document.getElementById('row_three').innerHTML == '') alert('Row 3 empty'); 

    } 

} 

    </script> 

    <style type="text/css"> 

    #mytable { 

    width: 305px; 

    height: auto; 

    border: 1px solid black; 

    padding:5px; 

    margin-top:10px; 

    } 

    #mytable div{ 

    width: 290px; 

    height: 100px; 

    margin:5px; 

    border: 1px solid red; 

    } 

    </style> 

    </head> 

    <body> 

    <input type="button" value="Check Rows" id="row_check"/> 

<div id="container"> 

</div> 

    </body> 

</html> 
Questions connexes