2012-12-15 50 views
1

我期待使用CSS的替代值#bigbox和#bigbox窗口只有在下拉菜單不等於排名或選擇一個位置...覆蓋CSS與下拉

這是我的第一篇文章,原諒任何格式錯誤!謝謝!

<html> 
    <style> 
    #bigbox { height:680px; } 
    #bigbox-window { height:680px; } 
    </style>  
    <script language="javascript" type="text/javascript"> 

    function setIframeSource() { 
     var theSelect = document.getElementById('location'); 
     var theIframe = document.getElementById('myIframe'); 
     var theUrl; 

     theUrl = theSelect.options[theSelect.selectedIndex].value; 
     theIframe.src = theUrl; 
    } 

    </script> 
    <body> 
    <div class="page page-pick_em"> 
     <h1>College Hockey Pick 'Em League</h1> 
     <form id="form1" method="post"> 
     <label> 
      <select id="location" onchange="setIframeSource()"> 
      <option value="">Select a location ...</option> 
      <option value="page/pick_em/standings.html">Standings</option> 
      <option value="page/pick_em/week01.html">Week 01</option> 
      <option value="page/pick_em/week02.html">Week 02</option> 
      </select> 
     </label> 
     </form> 
     <iframe SRC="page/pick_em/standings.html" width="100%" height="80%" id="myIframe" marginheight="0" frameborder="0" onLoad="autoResize('myIframe');"></iframe> 
    </div> 
    </body> 
<html> 
+1

只是爲了自己的將來參考,Java是不一樣的JavaScript。 – BenM

+0

「原諒任何格式錯誤」 - 或者,您可以使用這麼有幫助的預覽來重新檢查格式,然後點擊編輯幫助來修復它。 – millimoose

+0

另外:你有什麼嘗試?重寫類應該應用於什麼?爲什麼在您的代碼示例中包含'setIFrameSource()'時,它似乎與您的問題沒有任何關係? – millimoose

回答

0

好吧,當下拉不是您在問題中指定的選項時,這會更改CSS。

由於我不知道你在哪裏使用bigboxbigbox-window,以及你想要改變這些風格,只需按照我的示例並根據需要進行調整即可。

看到這個fiddle

theOptText = theSelect.options[theSelect.selectedIndex].text; 
if ((theOptText != "Select a location ...") && (theOptText != "Standings")) 
{ 
    document.getElementById("bigbox").style.borderColor = "#f00"; 
}