473,778 Members | 1,958 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Table height dynamically

Hi all,

I am struggling with a problem for a long time.

Problem statement:

I have a table and the table can contain n number of rows. i.e., the
table rows will be generataed out of a xml using a xslt. Now the problem
is I want the table to be only with a height of 200px. if this exceeds
beyond 200px, a vertical scroll bar along should appear. The horizontal
scroll bar should not appear.

I tried to used a javascript which will take the tbody and get the
height of the table row dynamically but the table row height is returned
by the javascript only if it is specified explicity else it returns
null. Further if I specify a value (say 50 px) and if the content in a
particular cell of that row is quite huge, naturally the cell height
become more but when accessed thru javascript its just returns the
height 50 px and not the height after which it is rendered.

Any help to solve this problem is greatly appreciated.

Thanks,
-Just dummy.

*** Sent via Developersdex http://www.developersdex.com ***
Aug 19 '05 #1
7 3083
Just Dummy wrote:
Hi all,

I am struggling with a problem for a long time.

Problem statement:

I have a table and the table can contain n number of rows. i.e., the
table rows will be generataed out of a xml using a xslt. Now the problem
is I want the table to be only with a height of 200px. if this exceeds
beyond 200px, a vertical scroll bar along should appear. The horizontal
scroll bar should not appear.

I tried to used a javascript which will take the tbody and get the
height of the table row dynamically but the table row height is returned
by the javascript only if it is specified explicity else it returns
null. Further if I specify a value (say 50 px) and if the content in a
particular cell of that row is quite huge, naturally the cell height
become more but when accessed thru javascript its just returns the
height 50 px and not the height after which it is rendered.

Any help to solve this problem is greatly appreciated.

Why not insert the table into a div with height of 200px, set overflow
to auto or scroll.
Mick
Aug 19 '05 #2
I can't use a div tag as the target browser is Firefox which doesn't
recognize the div tags.

*** Sent via Developersdex http://www.developersdex.com ***
Aug 19 '05 #3
ASM
Just Dummy wrote:
I can't use a div tag as the target browser is Firefox which doesn't
recognize the div tags.


can you repeat ? please
<div style="height: 200px; overflow: auto">
<table id="myTabl" ...>
<tr><td> ...
</table>
</div>

works fine with my FF (and even partialy with my IE)

--
Stephane Moriaux et son [moins] vieux Mac
Aug 19 '05 #4
Just Dummy wrote:
I can't use a div tag as the target browser is Firefox which doesn't
recognize the div tags.

Nonsense.
<div style="height:2 00px; overflow:scroll ">
<table id="standings" >
.....
</table>
</div>

Mick
Aug 19 '05 #5
I tried to put the table in div. Though I am able to see the scroll bar
but it doesn't satisfy the requirements. The reasong being
1) I don't want horizontal scroll bars. Is there a way to supress the
horizontal scroll bar along with vertical scroll bars peeing up when the
content exceeds the height of 200 px.
2) when <div style="height:2 00px; overflow:scroll ">
tag is applied around the <table> tag the vertical and horizontal
scroll bars appear to the full width of the page, though the table's
width is just half of the screen width.
3) Further if there are very few rows in the table, even then the scroll
bars appear.

Here is the code of the page.
<html><head><ti tle>Table Test</title>
<style type="text/css">
body { font-family: arial;}
table { border-color: darkblue; border-style: solid; border-width: 1px;
}
td, th {
font-family: Arial; font-size: 10pt; background-color: grey;
padding: 2px; padding-left: 6px; padding-right: 6px;
}
section-header{
background-color: darkblue; font-size : 18px; font-weight: bold;
font-style: normal; text-align: left; padding-left: 5px; vertical-align:
middle;
}
</style>
</head>
<body>
<div style="height:2 00px; overflow:scroll ">
<table cellpadding="0" cellspacing="1" width="800px">
<thead>
<tr style="backgrou nd-color:#008000;c olor:#ffffff;">
<th class="section-header">Name</th>
<th class="section-header">Positio n</th>
<th class="section-header">Number Added</th>
<th class="section-header">Number Removed</th>
</thead>
<tbody>
<tr><td>AAA</td><td>Left</td><td>122-456-789</td><td>122-456-788</td></t
r>
<tr><td>BBB</td><td>Left</td><td>123-456-789</td><td>123-456-788</td></t
r>
<tr><td>CCC</td><td>Right</td><td>233-456-789</td><td>233-456-788</td></
tr>
<tr><td>DDD</td><td>Left</td><td>234-456-789</td><td>234-456-788</td></t
r>
<tr><td>EEE</td><td>Right</td><td>238-456-789</td><td>238-456-788</td></
tr>
<tr><td>FFF</td><td>Right</td><td>235-456-789</td><td>235-456-788</td></
tr>
<tr><td>GGG</td><td>Left</td><td>236-456-789</td><td>236-456-788</td></t
r>
<tr><td>AAA</td><td>Left</td><td>122-456-789</td><td>122-456-788</td></t
r>
<tr><td>BBB</td><td>Left</td><td>123-456-789</td><td>123-456-788</td></t
r><tr>
<td>CCC</td><td>Right</td><td>233-456-789</td><td>233-456-788</td></tr>
<tr><td>DDD</td><td>Left</td><td>234-456-789</td><td>234-456-788</td></t
r>
<tr><td>EEE</td><td>Right</td><td>238-456-789</td><td>238-456-788</td></
tr>
<tr><td>FFF</td><td>Right</td><td>235-456-789</td><td>235-456-788</td></
tr>
<tr><td>GGG</td><td>Left</td><td>236-456-789</td><td>236-456-788</td></t
r>
</tbody>
</table>
</div>
</body>
</html>

Can sombody able to help me in this?

*** Sent via Developersdex http://www.developersdex.com ***
Aug 25 '05 #6
Just Dummy wrote:
I tried to put the table in div. Though I am able to see the scroll bar
but it doesn't satisfy the requirements. The reasong being
1) I don't want horizontal scroll bars. Is there a way to supress the
horizontal scroll bar along with vertical scroll bars peeing up when the
content exceeds the height of 200 px.
2) when <div style="height:2 00px; overflow:scroll ">
tag is applied around the <table> tag the vertical and horizontal
scroll bars appear to the full width of the page, though the table's
width is just half of the screen width.
3) Further if there are very few rows in the table, even then the scroll
bars appear.

[...]

This has nothing to do with JavaScript, post to either:

comp.infosystem s.www.authoring.html

or

comp.infosystem s.www.authoring.css
That doesn't preclude someone from here helping anyway...

--
Rob
Aug 26 '05 #7
ASM
Just Dummy wrote:
I tried to put the table in div. Though I am able to see the scroll bar
but it doesn't satisfy the requirements. The reasong being
1) I don't want horizontal scroll bars. Is there a way to supress the
horizontal scroll bar along with vertical scroll bars peeing up when the
content exceeds the height of 200 px.


Use : <div style="overflow : auto">
then scrollbars will appear only if needed.
And if you display inside overflowed div
- something with width smaller than div's one -> no horizontal lift
- something with height smaller than div's one -> no vertical lift
<div style="position : relative; width: 800px; margin: auto;
height: 200px; text-align: senter; overflow: scroll">
<table cellpadding="0" cellspacing="1" width="760px">
And ... tell me : it wasn't javascript question, no ?

--
Stephane Moriaux et son [moins] vieux Mac
Aug 26 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

19
13385
by: Logix | last post by:
Hello! I'm trying to make a sort of online page building system. In order to do this, I represent my page using a HTML table. One of the most basic templates would be a page divided in six equally proportioned rectangles: <table border="1" cellspacing="0" cellpadding="0" width="200" height="200"> <tr>
3
2330
by: rufus | last post by:
I am created a table dynamically and I have wrapped it in a div tag so that the user can scroll the table horizontally ie I have added an overflow property to the div. I dont want the user to be able to scroll vertically so I need to set the height of the div at runtime based on the number of table rows generated. Ideally I want the div scrollbars to sit just underneath the bottom of the table. I have looked around and haven't found...
11
3581
by: Norman L. DeForest | last post by:
Am I misunderstanding the CSS specifications or is Firefox (version 1.0.6) (and Opera) doing the wrong thing? It appears that Firefox 1.0.6 includes the border in width calculations for tables but not in height calculations. Oh, and Opera version 8.02 does the same thing. |<-->| |<-->| <------ border |<------------>| <------ table contents
2
2723
by: Steve Bottoms | last post by:
Hi, all! Using VB as code-behind in asp.net page... I have a TABLE control which I'm building dynamically. After the table is built, I'm trying to retrieve the HEIGHT property of that table (table.height.value) to be able to dynamically position the next elements on the form. However, this control property is coming back as -0- every time. I also try to get the table height with Javascript after-the-fact (table.style.height), but that...
6
10003
by: anirban.anirbanju | last post by:
hi there, i've some serious problem to add rows dynamically in a table. my table contains 5 cell. | check | from_value | to_value | color_text | color_value | --------------------------------------------------------------------------------- | | | | | | | | | | |
2
2375
by: James Black | last post by:
I am dynamically generating a table in IE to display some information. I will probably change it to divs later, but I just want to get it working properly first. In my div I have the following as the value of innerHTML: "<TABLE> <TR> <TD id=td6x vAlign=top align=right><IMG height=14 alt=Required src=\"/images/ci/icons/required.gif\" width=7 border=0 vAlign=\"top\"><INPUT id=anchor6x width=0 size=10
1
2239
by: James Black | last post by:
I am dynamically generating a table in IE to display some information. I will probably change it to divs later, but I just want to get it working properly first. In my div I have the following as the value of innerHTML: "<TABLE> <TR> <TD id=td6x vAlign=top align=right><IMG height=14 alt=Required src=\"/images/ci/icons/required.gif\" width=7 border=0 vAlign=\"top\"><INPUT id=anchor6x width=0 size=10
11
3198
by: bharathmngl | last post by:
now iam trying to add rows dynamically into the table when i click "ADD ROW" button. It should also have the option to delete the selected row. So Please help me to find code.... And also please tell me how to add textarea and radiobutton in to the dynamically created rows.. Here is my code; <html> <head> <title>Untitled Document</title>
3
1626
by: chris f | last post by:
In my table (ASP.NET 2) that is dynamically generated I have a cell that initially will only display N rows of text and hide the rest. (This is so that the rows have a small height and I can display more rows on a page.) When the user clicks on the cell (or maybe hovers the mouse over it) then I want the cell to expand to display all of the rows. Can someone help me out as to how I implement it? I've been told to use expanding DIVs but I...
0
9629
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9470
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10298
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10127
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10069
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8957
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6723
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
2
3627
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2865
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.