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

How to add hidden column to an html table 3

Status
Not open for further replies.

royboy75

Programmer
Feb 13, 2007
114
GB
Hello,

I have an html table that I would like to add a hidden column to, each table data in this column will have a hidden input field. How do I do that?
 
With a little bit of CSS, thats how...

Code:
<td style="visibility:hidden;">

Cheers

Nick :)
 
You don't need to add a "hidden" column to have a hidden input field, as - guess what - hidden input fields are hidden.

You can place them anywhere you like, and they do not show up.

Hope this helps,
Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
I know that but how do I set an input field for EACH table row?
 
Have to agree with monksnake...

I realise you probably have what you want now but if your going to learn we may as well show you how to do something correctly!

I know that but how do I set an input field for EACH table row?

What exactly do you mean by this?

Dont mean to be patronising but you know you can half more than one element within a table data cell ("<td>")? <td><input type=text><input type=hidden></td>
 
Hey,

Yes I know that, it's just that with this code: <td><input type=text><input type=hidden></td>
The input field is hidden but not the column itself.
I should have been more clear about that, sorry guys and thanks!

Roy
 
You can hide the <tr> instead of all the <td>'s in a row. That way you only have one element to hide per row.

visibility:hidden

will simply make the element invisible, but it will still take up the space it occupies while it is visible. If you want to remove that space as well, use

display:none


[monkey][snake] <.
 
Let's rewind for a minute here.

When you say
I have an html table that I would like to add a hidden column to, each table data in this column will have a hidden input field.
What exactly do you mean by a "hidden input field"? Do you mean an [tt]<input type="hidden">[/tt] that nobody will ever see, or do you mean some other kind of [tt]<input>[/tt] that you're initially hiding from view, but can be revealed by user action via Javascript.

If it's an [tt]<input type="hidden">[/tt], there's really no reason to create a separate [tt]<td>[/tt] for it at all. Just put it into one of the other [tt]<td>[/tt]s in the row (or anywhere else in the [tt]<form>[/tt] element for that matter). Creating extra [tt]<td>[/tt]s just for the hidden [tt]<input>[/tt]s and then hiding them with CSS is just making unnecessary work for yourself.

If you want to hide/reveal a column of your table (and its contents) using Javascript, you're probably best advised to give each hidden [tt]<td>[/tt] a class and manipulate the properties of that class in your script. Don't ask me how to do it though - it's a question for the Javascript forum.

-- Chris Hunt
Webmaster & Tragedian
Extra Connections Ltd
 
If it's an <input type="hidden">, there's really no reason to create a separate <td> for it at all. Just put it into one of the other <td>s in the row (or anywhere else in the <form> element for that matter). Creating extra <td>s just for the hidden <input>s and then hiding them with CSS is just making unnecessary work for yourself.

Not wanting to appear bitter or anything... but I pointed that out a while ago... perhaps my post was misunderstood by the OP?

Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top