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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Changing table & td width

Status
Not open for further replies.

staffa

Programmer
Jan 31, 2005
32
DK
I'm having problems changing the width of a table and a td inside the table.

My code is:
Code:
<script type="text/javascript" language="javascript">
function resizeWin(w){
	document.getElementById("mainTBL").style.width = w;
	w2 = w - 40;
	document.getElementById("mainHeaderTD").style.width = w2;
}
</script>

and the link to call the function:
Code:
<a href="<?php echo $_SERVER['PHP_SELF']; ?>" onClick="resizeWin(700)">700px</a>

Hope someone can help.

staffa
 
style.width changes should always give a units suffix - in this case:
Code:
    document.getElementById("mainTBL").style.width = w + 'px';
...
    document.getElementById("mainHeaderTD").style.width = w2 + 'px';
 
Thanks.

I forgot to describe my problem earlier. The units suffix wasn't a problem, it gives the same result, but emidiatly after changing to 700px, it changes back.

I've tryed using this.blur() in many ways, but then it doesn't change, so I'm really lost.

staffa
 
Ah, I think I begin to see. You are resizing your window in an href that is reloading your page. Don't reload the page! It isn't wanted.
 
Thanks again. I didn't think of the reloading.
But it's odd that i tryed using href="javascript:void()" but it didn't work, but now it does.

staffa
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top