Reply
Change Table Width onClick - Save State Question
Old 09-24-2008, 09:00 PM Change Table Width onClick - Save State Question
Junior Talker

Posts: 4
Hi am using a button to change the size of a table and I had a few questions about it.

I can change the table width, but then I'm not sure how to chnage it back again to the original state. Is that done with return true/false?

Also, this script is on a page where there is a form, so it in a constant state of refresh, can I use the onload function to keep it's state on reload? I have other reload functions at the bottom of the page too (CngColor & drg), so I'm not sure how to get those to play nice together.

Below is my script:

Thanks.



HTML Code:
<html>
<head>
<script>
function switchheight()
{
document.getElementById('width').width = '200px';
}
</script>
</head>

<body>
<table width="500" id="width">
<tr>
<td bgcolor="green">demo table</td>
</tr>
</table>

<input type="button" value="width" onclick="switchheight()">


<script type="text/javascript">

window.onload=
function 1() {
    var sels = document.getElementsByTagName('select');
    CngColor(sels[0]);
    CngColor2(sels[1]);
    CngColor3(sels[2]);
    CngColor4(sels[3]);
         }

function 2() {
    var wid = document.getElementsById('width');
    switchheight(wid[0]);


    var drg = document.getElementsByTagName('div');
    if(readCookie('wd')) {
        drg[0].style.visibility=readCookie('wd');
        }
};

</script>

</body>
</html> 



mendir200 is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
Old 09-25-2008, 05:50 AM Re: Change Table Width onClick - Save State Question
Average Talker

Posts: 23
Hi,usually I use the property “offsetWidth” to get the current width of the table before changing it .and save it to a variable.like this: var theOldWidth=document.getElementById('width').offse tWidth;

Last edited by softhink : 09-25-2008 at 06:13 AM.
softhink is offline
Reply With Quote
View Public Profile
 
Old 10-01-2008, 11:28 AM Re: Change Table Width onClick - Save State Question
Junior Talker

Posts: 4
Sweet thanks so much for the advice!
mendir200 is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Change Table Width onClick - Save State Question
 

Thread Tools

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

vB 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.11897 seconds with 12 queries