简体   繁体   中英

HTML/JS Update one table cell from another table cell

Is it possible to update one table cell from another table cell?

Example: I have a MediaWiki site, and on Page A I have a table cell like this:

<td style="background: grey; color: black;"> Proposed</td>

I want to be able to update the colour in this cell (say.. to Green) and it will update a completely different table cell on Page B (changing it to Green also).

So is there a way to dynamically link two table cells, so that when one cell is changed, the other cell is also update to reflect the same change.

I don't think that what you're proposing is a good idea. The color of one cell shouldn't depend on the color of some cell in a completely different table. Instead the colors of both cells should depend on some common resource.

That common resource could be a CSS style, using the same CSS class for both cells (as Andrew suggested in a comment).

For example, you would define the CSS class proposed-cell (most likely in MediaWiki:Common.css ):

.proposed-cell 
{
    color: black;
}

And then use it like this:

<td class="proposed-cell">

Or it could be a MediaWiki template, that you would reference from cell style.

For example, you could create the page Template:Proposed color , whose contents will be black .

Then you would use it like this:

<td style="color: {{Proposed color}};">

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM