Change Table Width in Javascript or Dhtml or Css

Le
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 !
Vos réponses
Gagnez chaque mois un abonnement Premium avec GNT : Inscrivez-vous !
Trier par : date / pertinence
vd
Le #12643791
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 !



.



Bob Barrows
Le #12643771
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"
Giedrius
Le #12643611
"Bob Barrows" 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
Bob Barrows
Le #12643561
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"
Giedrius
Le #12643171
"Bob Barrows" 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.
Publicité
Poster une réponse
Anonyme