Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to set table height w/ javascript?...variables?

Status
Not open for further replies.

WhiteTiger

Programmer
Jun 26, 2001
605
US
How do I set a variable that a table can read for the height of the table?...

I need to set the table to a certian height, but I figured out that it wasn't the parameter I was using, it was being able to have the table call the variable.
Regards,
AnthLOLny
----------------------------------------
The Learning process is just a way to get rid of all the stupids in your head.

Now where's that cute little kitten? :-X
 
One way to doit is build the write your html

EG

Code:
<SCRIPT LANGUAGE=&quot;JavaScript&quot;>
<!-- start hide



var HTMLstr = &quot;&quot;;    // string to send to document.write()

var sw = screen.availHeight/2;

HTMLstr += '<body bgcolor=&quot;#99FFFF&quot; link=&quot;#660000&quot; vlink=&quot;#660000&quot; alink=&quot;#660000&quot;><h1 align=&quot;center&quot;>EG<</h1>';
HTMLstr += '<TABLE WIDTH=100% HEIGHT='+sw+'  BORDER=1>';
HTMLstr += '<TR><TD>A</TD> <TD>B</TD><TD>C</TD><TD>D</TD></TR>';
HTMLstr += '<TR><TD>1</TD> <TD>2</TD><TD>3</TD><TD>4</TD></TR>';
HTMLstr += '<TABLE>';
HTMLstr += '</body></html>';
   
document.write(HTMLstr);  // write HTMLstr

// end hide -->
</SCRIPT>
Billy H

bhogar@acxiom.co.uk
 
I can't have it write it...it's an ASP...

Is there a better way?
Regards,
AnthLOLny
----------------------------------------
The Learning process is just a way to get rid of all the stupids in your head.

Now where's that cute little kitten? :-X
 
I'm using it within a VBS, and an ASP file, I'm trying to avoid having to use document write...it just gets messy that way.
Regards,
AnthLOLny
----------------------------------------
The Learning process is just a way to get rid of all the stupids in your head.

Now where's that cute little kitten? :-X
 
I no it still uses a form of document.write() but only for the table header.


Code:
<SCRIPT LANGUAGE=&quot;JavaScript&quot;>
  document.writeln(&quot;<TABLE WIDTH=100% BORDER=1 HEIGHT=&quot;+screen.availHeight/2+&quot;>&quot;);
</SCRIPT>
    <TR> <TD>1</TD> <TD>2</TD> <TD>3</TD> <TD>3</TD></TR>
    <TR> <TD>a</TD> <TD>b</TD> <TD>c</TD> <TD>d</TD></TR>
</TABLE>
Billy H

bhogar@acxiom.co.uk
 
I don't think I understand exactly what you want to do, but maybe this example will help:
Code:
<html>
<head>
<script language=&quot;javascript&quot; type=&quot;text/javascript&quot;>
function changeheight() {
var tableheight = document.forms[0].text1.value
document.getElementById('table1').style.height = tableheight
}
</script>
</head>
<body>
<table id=&quot;table1&quot; border=&quot;1&quot;>
<tr>
	<td>Test</td>
</tr>
</table>
<form>
Enter Height: <input type=&quot;text&quot; name=&quot;text1&quot; size=&quot;2&quot; />
<input type=&quot;button&quot; value=&quot;Change Height&quot; onclick=&quot;changeheight()&quot; />
</form>
</body>
</html>
 
Nevermind, sheesh, I got it...I didn't want to write anything!...

It was
Code:
document.all(&quot;main&quot;).height= document.body.clientheight - 28

thanks anyways.
Regards,
AnthLOLny
----------------------------------------
The Learning process is just a way to get rid of all the stupids in your head.

Now where's that cute little kitten? :-X
 
and I had to give the table the id of 'main'
Regards,
AnthLOLny
----------------------------------------
The Learning process is just a way to get rid of all the stupids in your head.

Now where's that cute little kitten? :-X
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top