Forums: Index Help desk Alternating infobox at the click of a button

Hi there. I'm looking to add a feature into an existing template on Robot Wars Wiki. 99% of the coding on our Wiki has been me experimenting with trial and error, but this one is beyond me.

Take a robot like Panic Attack.

Basically there were six versions of the robot ever made. As it is, we can only display one image and one set of statistics; the rest is spread throughout the article.

What I would like is the feature that COD Wiki (and others, but this is the only one I can find) has for the AK-47.

See how you can click the "tab" at the top to change from COD4 to MWR? I want to be able to program that onto our Template:Robot. I want all of the information besides the heading to change depending on which tab is selected.

My questions are as follows:

1. Is it possible to have one template that we can then program a number of "tabs". Some robots have one appearance and therefore don't need a tab, and others have 8. 2. Do I need to create two templates, one for non-tab robots and one for tab robots, OR do I need to create 12 templates based on how many versions of the robot there are?

Can someone help me? I'm not even sure what the feature is called, so am lost for where to start. Toon Ganondorf (t c) 10:29, December 5, 2017 (UTC)

Additionally, I cannot follow this forum to get email updates when people edit it, so can someone please drop a quick message on my talk page if there's activity here so I can check it? Toon Ganondorf (t c) 10:33, December 5, 2017 (UTC)
Actually, this is possible using the <gallery> tag. Take the following code:
PanicAttack.jpg | Panik Attack
Roadblock.jpg   | Road Block

That would then cause Panik Attack's image to be the default, but allow for a tab called "Road Block" that, when pressed, would show Road Block's image. This can be included as-is above in the images variable without requiring modifications to the main template.--TwoTailedFox (talk) 19:15, December 7, 2017 (UTC)

Community content is available under CC-BY-SA unless otherwise noted.