Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
can i write a script that will change the size of a table?
Old 06-05-2007, 12:23 PM can i write a script that will change the size of a table?
Junior Talker

Posts: 3
Trades: 0
hi everybody!
Im building a website and the problem is that the design is good for resolutions over 1024 by 768. somehow i manged to reduce one of the tables in one of the pages the it will be ok for resolutions under 1024 by 768.
i was wondering if you can help me make a js script that will fit this specific table to the screen resolution? (i know what sizes it should be to fit in every resolution)

thanks everybody,
Ron.
ihavenonickname is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 06-05-2007, 04:34 PM Re: can i write a script that will change the size of a table?
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
Simple.
First, give a unique id to each of your tables.
Then:
HTML Code:
<script type="text/javascript">
function resize(id, width){
  var trg=document.getElementById(id);
  if(trg)
    trg.style.width=width+"px";
  }
}
</script>

<table id="tbl1" summary="a random table" style="width:500px;" border="1">
  <tbody>
    <tr>
      <th>
        Table 1
      </th>
    </tr>
    <tr>
      <td>
        Content
      </td>
    </tr>
  </tbody>
</table>

<a href="javascript:resize('tbl1',900);">Resize table 1 to 900 px</a><br/>
<a href="javascript:resize('tbl1',200);">Resize table 1 to 200 px</a><br/>
__________________
Only a biker knows why a dog sticks his head out the window.

Last edited by tripy; 06-05-2007 at 04:36 PM..
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Old 06-05-2007, 08:34 PM Re: can i write a script that will change the size of a table?
mgraphic's Avatar
Truth Seeker

Latest Blog Post:
JAMISONTUNES
Posts: 2,898
Name: Keith Marshall
Location: Connecticut
Trades: 0
I suggest just to define 100% for the table width and it will always be the full width of the browser window. The reason for this is if the users window is opened smaller than the screen resolution, it will not make any difference to the user because he/she will still need to scroll side to side to view the entire page. Also other elements such as scrollbars, status bars, and other background apps taking the desktops realestate may override the browser from opening full screen.

However, you can use javascript to get the screen size by the defined values of screen.width and screen.height
__________________

<mgraphic /> - I don't have a solution but I admire the problem.
mgraphic is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to can i write a script that will change the size of a table?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.12041 seconds with 12 queries