Twitter iPhone pliant OnePlus 11 PS5 Disney+ Orange Livebox Windows 11

Change Table Width in Javascript or Dhtml or Css

5 réponses
Avatar
NicoAgenci
Hello,

Is it possible to change the width in a table with jvascript or dhtml ?

More details :

I have :

<table>
<tr>
<td width="">Content : Img and Text</td>
<td width="180px">Content : Img and Text</td>
</tr>
</table>

And i want to change the size of the second <td> (<td width="180px">) with
javascript or dhtml or css

Have you do this one yet ???

Thanx,
Nico !

5 réponses

Avatar
vd
It's possible, you must give a name to the second td and
then with javascript document.name.width=YYYpx

it's my mind :-)

this page must be reloaded with your parameter (by exemple
YYYpx)

best regards

-----Message d'origine-----
Hello,

Is it possible to change the width in a table with


jvascript or dhtml ?

More details :

I have :

<table>
<tr>
<td width="">Content : Img and Text</td>
<td width="180px">Content : Img and Text</td>
</tr>
</table>

And i want to change the size of the second <td> (<td


width="180px">) with
javascript or dhtml or css

Have you do this one yet ???

Thanx,
Nico !



.



Avatar
Bob Barrows
NicoAgenci wrote:
Hello,

Is it possible to change the width in a table with jvascript or dhtml
?

More details :

I have :

<table>
<tr>
<td width="">Content : Img and Text</td>
<td width="180px">Content : Img and Text</td>
</tr>
</table>

And i want to change the size of the second <td> (<td width="180px">)
with javascript or dhtml or css

Have you do this one yet ???

Thanx,
Nico !



Here is a link to the dhtml reference:

http://msdn.microsoft.com/workshop/author/dhtml/dhtml_node_entry.asp

It's very easy. Give the TD element an id:
<td id="cellWhoseWidthIWantToChange" width="180px">Content : Img and
Text</td>

Then, in your code (assuming IE):
cellWhoseWidthIWantToChange.style.width 0

HTH,
Bob Barrows




--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Avatar
Giedrius
"Bob Barrows" wrote in message
news:
NicoAgenci wrote:
> Hello,
>
> Is it possible to change the width in a table with jvascript or dhtml
> ?
>
> More details :
>
> I have :
>
> <table>
> <tr>
> <td width="">Content : Img and Text</td>
> <td width="180px">Content : Img and Text</td>
> </tr>
> </table>
>
> And i want to change the size of the second <td> (<td width="180px">)
> with javascript or dhtml or css
>
> Have you do this one yet ???
>
> Thanx,
> Nico !

Here is a link to the dhtml reference:

http://msdn.microsoft.com/workshop/author/dhtml/dhtml_node_entry.asp

It's very easy. Give the TD element an id:
<td id="cellWhoseWidthIWantToChange" width="180px">Content : Img and
Text</td>

Then, in your code (assuming IE):
cellWhoseWidthIWantToChange.style.width 0



I would recommend using
document.getElementById('cellWhoseWidthIWantToChange').style.width 0
since it is the official standart and the code above doesn't always work
correctly.

I had to rewrite half of my intranet application (based strictly on IE 5.5)
once, because of that problem
Avatar
Bob Barrows
Giedrius wrote:

I would recommend using
document.getElementById('cellWhoseWidthIWantToChange').style.width 0
since it is the official standart and the code above doesn't always
work correctly.

I had to rewrite half of my intranet application (based strictly on
IE 5.5) once, because of that problem


You probably had that problem because you had a FORM tag enclosing the
elements you wished to refer to. You could have avoided the getElementByID
by explicitly naming the form which contained the element you wished to
refer to:
myform.cellWhoseWidthIWantToChange.style ....

I usually assign the result of getElementById to a variable so I can use it
more than once without multiple calls to the function.

HTH,
Bob Barrows
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Avatar
Giedrius
"Bob Barrows" wrote in message
news:ug#
Giedrius wrote:

> I would recommend using
> document.getElementById('cellWhoseWidthIWantToChange').style.width 0
> since it is the official standart and the code above doesn't always
> work correctly.
>
> I had to rewrite half of my intranet application (based strictly on
> IE 5.5) once, because of that problem
You probably had that problem because you had a FORM tag enclosing the
elements you wished to refer to. You could have avoided the getElementByID
by explicitly naming the form which contained the element you wished to
refer to:
myform.cellWhoseWidthIWantToChange.style ....

I usually assign the result of getElementById to a variable so I can use


it
more than once without multiple calls to the function.



No, actually I didn't use not even one form element in the app. Ah,
nevermind...

I believe getElementById should always be used, to get the element.
Of course, if you want to access the element three times of more, you should
create a variable, which whould be reference to the element.