Jump to content

Recommended Posts

Hi I have a page with a div box. By default it is set to "hidden". On a click I want to make the box visible and then subject subject to conditions, draw a table inside the div (At this stage it is just a 10x10 table) ,

When I do click and run the javascript function  I dont get the div box just get a blank page with the table, Can anyone help me please  ?

I hope I have included all the information needed . Thanks

 

from my page I call the function visible()

 

function visible() {

document.getElementById("window").style.visibility = "visible";

drawallocatetable()

 

function drawallocatetable() {

document.write('<center><table width="200" border="0">');

for (j=1;j<=10;j++) {

          document.write('<tr>');

for (i=1;i<=10;i++) {

          document.write('<td>' + i*j + '</td>');

}

          document.write('</tr>');

}

          document.write('</table></center>');

}

 

my HTML/PHP code contains this Div tag and at this stage no table is drawn

 

<div id='window' >The Title </div>

 

and this in the <style> ,

 

#window {

position:absolute ;

width: 600px;

height:400px;

background-color:#39C ;

border: 4px solid black;

z-index:1 ;

visibility:hidden ;

left:50% ;

margin-left:-300px;

Link to comment
https://forums.phpfreaks.com/topic/174994-solved-table-inside-a-div/
Share on other sites

document.write starts writing at the beginning of the document, overwriting what was originally there.  Use innerHTML when building your table instead.  Also, your visibility toggle should be toggling between hidden and block, as a div is a block element.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.