[thelist] Javascript - Calling Variables

Saila, Craig Craig.Saila at bgminteractive.com
Tue Jun 25 13:36:01 CDT 2002


> -----Original Message-----
> From: Dave Stevens [mailto:stem at stemofficial.co.uk]
> Sent: June 25, 2002 2:14 PM
> <script language="JavaScript" type="text/javascript">
>     <!-- Begin
>       function GetRes() {
>                  var width = (screen.width - 10);
>                  var height = (screen.height - 150);

/*add this line*/ return width

>       }
>     //  End -->
> </script>

The next time you call GetRes, it will return the value of width.

> with JS - prefer PHP :D) then I now want to use the width
> value in the body of the page, to set the width of a table,
> so how exactly would I do that?

The ideal way would be to grab the width and set the table's width via
the DOM, for example:
 width = GetRes()
 document.getElementById("theIDofTheTableYouWant").style.width = width
Or
 width = GetRes()

document.getElementByTagName("TABLE").childNodes.item(0).setAttribute("w
idth",width)

Or you could write it in the document like so:
<script type="text/javascript">document.write(GetRes())</script>

--
Cheers,

Craig Saila
------------------------------------------
craig at saila.com : http://www.saila.com/
------------------------------------------



More information about the thelist mailing list