Brauche Hilfe bei Script

Hallo zusammen,
ich kenne mich nicht sooo gut mit JavaScript aus und habe in meinem Code irgendwo einen Fehler
 leider finde ich ihn nicht :frowning:

Das ist der JavaScript Code

function tpl(i) { var t; var s; var b; switch (i) { case "1": document.getElementById('tempest_off').id='tempest'; t = '1'; if (s = '1') { document.getElementById('style').id='style_off'; s = '0'; } else { if (b = '1') { document.getElementById('buisiness').id='buisiness_off'; b = '0'; } } break; case "2": document.getElementById('style_off').id='style'; s = '1'; if (t = '1') { document.getElementById('tempest').id='tempest_off'; t = '0'; } else { if (b = '1') { document.getElementById('buisiness').id='buisiness_off'; b = '0'; } } break; case "3": document.getElementById('buisiness_off').id='buisiness'; b = '1'; if (t = '1') { document.getElementById('tempest').id='tempest_off'; t = '0'; } else { if (s = '1') { document.getElementById('style').id='style_off'; s = '0'; } } break; default: break; } }

Und der dazugehörige CSS

           #tempest
              {
                height: 200px;
                width: 200px;
                background-color: red;
              }
              
              #tempest_off
                {
                  display: none;
                }
                          
            #style
              {
                height: 200px;
                width: 200px;
                background-color: blue;
              }
              
              #style_off
                {
                  display: none;
                }
                 
            #buisiness
              {
                height: 200px;
                width: 200px;
                background-color: green;
              }
              
              #buisiness_off
                {
                  display: none;
                }                

Sowie HTML Code:

<select class="input" name="template">
          <option value="tempest" onclick="tpl('1');">Tempest</option>
          <option value="style" onclick="tpl('2');" >Style</option>
          <option value="buisiness" onclick="tpl('3');" >Buisiness</option>
        </select>
<div id="tempest_off">
          <p class="text">
            <i>ErklÀrungstext ... blablabla</i>
          </p>
          <p class="img">
            <a><img></a>
          </p>
        </div>
        
        <div id="style_off">
          <p class="text">
            <i>ErklÀrungstext ... blablabla</i>
          </p>
          <p class="img">
            <a><img></a>
          </p>
        </div>
        
        <div id="buisiness_off">
          <p class="text">
            <i>ErklÀrungstext ... blablabla</i>
          </p>
          <p class="img">
            <a><img></a>
          </p>
        </div>

Das Problem liegt daran, dass man ohne Probleme zwischen “Style” und “Tempest” hin und her schalten kann, jedoch “buisiness” nciht meh verschwinden will, wenn es einmal da ist.

Ich hoffe Ihr könnt mir helfen :smiley:

Ein Link zur Demo wÀre praktisch

Na klar :slight_smile:

Hier ist mal die Testseite