I am trying to repeat <div> several times
because I have a table and the design of each "2" rows is repeated.
Is this possible? or there is another way?

the scribt I am using is:

<table class="style1" dir="ltr" >
            <script type = "text/javascript">

                var rows = 10; // the value will be taken from DB later
                for (var i = 0; i < rows; i++) {//
                    document.write('<div class= \"msgDiv\">');
                    document.write('<tr><td>Patient\sUserName</td><td> X </td></tr> '+
                     '<tr><td> System\'sResult</td><td>'+ i +'</td></tr>');
                     document.write('</div>');//something isn't working well><

the problem is that the <div> is repeated 10 times and the cells are created but each in separate location

Edited by __avd: Added [code] tags.

5 Years
Discussion Span
Last Post by farashh

This is probably because div is a block element, it doesn't want to aline things side by side. Add display: inline-block to your css for the divs and they should start to line up properly.


Try this,

<script type="text/javascript">
      var tab1=document.getElementById("tab1");

         var bdy=document.createElement("tbody");
         bdy.innerHTML="<div><tr><td>Patients's UserName</td><td> X 

</td></tr><tr><td>System'sResult</td><td>"+ i +"</td></tr></div>"; 


   <table id="tab1" border="1"></table>

I think the problem is that you're using <tr><td> without nestinfg them in a table. I think rows and collumns should only be used in tables.try


see if it works.The alternate could be to nest multiple <div>s inside one main <div> and then positioning them in css.


Sarama2030, there is quite clearly a <table> element at the start and a </table> element at the end. The OP is using document.write to insert the code between those two tags


thanx to all,
but still it seems it does not work
"adatapost" what you did showed the table
"but what i did in css is completly ignored in google chrome and believe me you do not want to see the result in IE9"

I am thinking to change the table idea and us 2 <p> instead. i hope it will work

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.