Old 04-29-2008   #1 (permalink)
Registered User
 
Join Date: Apr 2008
Posts: 2

Scrollbar not showing up (CSS)

I am new to HTML/JavaScripts.
I want to construct a table dynamically and remove it on click of a button. The table should have scrollbar in it. I am unable to get a scrollbar even after making use of "overflow : auto;". The scrollbar shows up when I click on the show table button for the second time. Please help.
My code is written below :

<HTML>
<HEAD>
<TITLE>Picking Attribute from Inline Table</TITLE>
<SCRIPT>
function drawInlineTable()

{

var body = document.getElementsByTagName("BODY")[0];

var prevcontent = body.innerHTML;

body.innerHTML = prevcontent + '<DIV STYLE="width: 900">'
+'<TABLE cellspacing=0 cellpadding=2 id=tableid0>'
+'<COL WIDTH=200><COL WIDTH=250><COL WIDTH=370><COL WIDTH=20>'
+'<TR>'
+'<TH width=200 bgcolor="lightgrey">Category</TH>'
+'<TH width=250 bgcolor="lightgrey">Name</TH>'
+'<TH width=370 bgcolor="lightgrey">Description</TH>'
+'<TH width=20 bgcolor="lightgrey">Button</TH>'
+'<TH width=60 bgcolor="lightgrey">&nbsp;</TH>'
+'</TR>'
+'</TABLE>';

var content = body.innerHTML;

body.innerHTML = content + '<DIV STYLE="overflow: auto; width: 900px; height: 50; border-left: 1px gray solid; border-bottom: 1px gray solid; padding:0px; margin: 0px">'
+ '<TABLE cellspacing=0 cellpadding=2 id=tableid1>'
+ '<COL WIDTH=200><COL WIDTH=250><COL WIDTH=370><COL WIDTH=20>'
+ '</TABLE>';

var tblBody = document.getElementsByTagName("TBODY")[1];


for (var j = 0; 1 > j; j++)
{
var row = document.createElement("TR");

for (var i = 0; 3 > i; i++)
{
var cell = document.createElement("TD");
var cellText = document.createTextNode("cell is row "+j+", column "+i);
cell.appendChild(cellText);
row.appendChild(cell);
}

var myButton = document.createElement("TD");
myButton.innerHTML = '<input type="button" value="Attach" onclick="selectANDhide(this.parentNode.parentNode. rowIndex);">';
row.appendChild(myButton);
tblBody.appendChild(row);
}

alert(body.innerHTML);
}

function selectANDhide(x)
{
var tbl = document.getElementById("tableid1");
var resultArray = new Array();

for (j = 0; j < (tbl.rows[x].childNodes.length) - 1; j++)
{
if (tbl.rows[x].childNodes[j].style)
{
resultArray.push(tbl.rows[x].childNodes[j].innerHTML);
}
}

var resultString = "";

for (k = 0; k < resultArray.length; k++)
{
resultString += k + ": " + resultArray[k] + "\n";
}

alert(resultString);

for (var j = 0; 1 > j; j++)
{
document.getElementById("tableid1").deleteRow(0);
}

document.getElementById("tableid0").deleteRow(0);

alert(x);

var body1 = document.getElementsByTagName("BODY")[0];
body1.innerHTML= '<input type="button" value="Pick Attribute" onClick ="drawInlineTable();">'

}
</SCRIPT>
</HEAD>


<BODY>
</BODY>
<INPUT type="button" value="Pick Attribute" onClick ="drawInlineTable();">
</HTML>
soshah is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 04-29-2008   #2 (permalink)
Registered User
 
Join Date: Apr 2008
Location: A rock floating in space
Posts: 2

By briefly looking at the code, I am going to assume it might be that you do not have a declared DOCTYPE. Try using HTML 4.0 to see if that will work.

HTML DOCTYPE TAG
A List Apart: Articles: Fix Your Site With the Right DOCTYPE!
O'Reilly Network -- DOCTYPE Explained
Leprakawn is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 04-29-2008   #3 (permalink)
Registered User
 
Join Date: Apr 2008
Location: A rock floating in space
Posts: 2

And the <input> tag should go within the <body> </body> tags like so:
Code:
<BODY>
<INPUT type="button" value="Pick Attribute" onClick ="drawInlineTable();" />
</BODY>
Leprakawn is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
scrollbar in a frame Ceaufy HTML / PHP / ASP / JS 3 08-05-2008 12:43 PM
HTML Scrollbar SaikonoYume HTML / PHP / ASP / JS 5 04-20-2007 09:34 PM
Scrollbar, making it a gradient? ecntrc HTML / PHP / ASP / JS 10 05-02-2006 06:40 PM
horizontal scrollbar in iframe problems julio7 HTML / PHP / ASP / JS 2 04-28-2004 06:36 PM
Scrollbar in a table? malboroman HTML / PHP / ASP / JS 17 12-23-2003 03:14 AM


All times are GMT +1. The time now is 05:52 PM.
Content Relevant URLs by vBSEO 3.2.0

Design & Content © BioRUST 2008 :: PRIVACY STATEMENT :: LEGAL INFORMATION :: ADVERTISING MEDIA KIT