theflyingminstr
09-24-2008, 10:27 PM
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>
<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>
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>
<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>