2015-04-22 209 views
1

我只是不明白爲什麼這個函數插入文本框的值爲不可見。我嘗試將隱藏的字段更改爲普通的可見字段,但這也沒有幫助。非常感謝啓蒙。 以下是完整的頁面代碼,對德國遺憾:當我更新純文本框中的文本框的值,文本值是不可見的

<head> 
    <style> 
     body{ 
      background: #111; 
      color:  #d00; 


     } 

     input{ 
      background: #111; 
      color:  #c90; 
      font-size: 1.4em; 
      font-weight: bold; 
      border-radius: 7px; 

     } 


    #aaa{ 
      top:  10%; 
      height:  20%; 

      left:  30%; 
      width:  40%; 

      background: #133; 
      color: teal; 

      font-weight: bold; 

      border: inset 3px #2d2d2d; 
      -moz-border-top-left-radius:8px; 
      -webkit-border-top-left-radius: 8px; 
      -o-border-top-left-radius: 20px; border-top-left-radius: 8px; 

      -moz-border-top-right-radius:8px; 
      -webkit-border-top-right-radius: 8px; 
      -o-border-top-right-radius: 20px; border-top-right-radius: 8px; 

       -moz-border-bottom-left-radius:8px; 
      -webkit-border-bottom-left-radius: 8px; 
      -o-border-bottom-left-radius: 20px; border-bottom-left-radius: 8px; 

       -moz-border-bottom-right-radius:8px; 
      -webkit-border-bottom-right-radius: 8px; 
      -o-border-bottom-right-radius: 20px; border-bottom-right-radius: 8px; 
    }  

    #aaa{ 
      top:  10%; 
      height:  20%; 

      left:  20%; 
      width:  60%; 

      background: #333; 
      color: #d00; 
      padding: 2%; 

      font-weight: bold; 

      border: outset 3px #2d2d2d; 
      -moz-border-top-left-radius:8px; 
      -webkit-border-top-left-radius: 8px; 
      -o-border-top-left-radius: 20px; border-top-left-radius: 8px; 

      -moz-border-top-right-radius:8px; 
      -webkit-border-top-right-radius: 8px; 
      -o-border-top-right-radius: 20px; border-top-right-radius: 8px; 

       -moz-border-bottom-left-radius:8px; 
      -webkit-border-bottom-left-radius: 8px; 
      -o-border-bottom-left-radius: 20px; border-bottom-left-radius: 8px; 

       -moz-border-bottom-right-radius:8px; 
      -webkit-border-bottom-right-radius: 8px; 
      -o-border-bottom-right-radius: 20px; border-bottom-right-radius: 8px; 

      position: absolute; 
    }  
      #geheime{ 

       visibility: hidden; 
      } 

      #ang{ 
        top:  7%; 
        height:  20%; 

        left:  10%; 
        width:  80%; 
        text-shadow: 2px 2px #111; 
        font-weight: bold; 

        position: absolute; 
      }  

      #kaste{ 
        top:  30%; 
        height:  20%; 

        left:  10%; 
        width:  80%; 

        font-weight: bold; 

        position: absolute; 
      }  

      #fichs{ 
        top:  68%; 
        height:  20%; 

        left:  20%; 
        width:  30%; 

        font-weight: bold; 

        position: absolute; 
      }  

      #schicks{ 
        top:  68%; 
        height:  20%; 

        right:  20%; 
        width:  30%; 

        font-weight: bold; 

        position: absolute; 
      }  

    .klKnopfR { 
      background: linear-gradient(to bottom, #f11 0%, #400 100%); /* W3C */ 

     color:#ddd; 
     font-weight: bold; 
     font-size: 1.4em; 
        text-shadow: -1px -1px #411; 
      /*-moz-border-top-right-radius:8px;*/ 
      /*-webkit-border-bottom-left-radius: 8px;*/ 
      /*-o-border-bottom-right-radius: 20px; */ 
      border-radius: 8px; 
    } 

    .klKnopfG { 
     background: linear-gradient(to bottom, #1f1 0%, #141 100%); /* W3C */ 
     color:#ddd; 
     font-weight: bold; 
     font-size: 1.4em; 
        text-shadow: -1px -1px #141; 
      /*-moz-border-top-right-radius:8px;*/ 
      /*-webkit-border-bottom-left-radius: 8px;*/ 
      /*-o-border-bottom-right-radius: 20px; */ 
      border-radius: 8px; 
    } 


    .klB { 
     background: #4ff; 
     color:#d00; 
    } 


</style> 

  <?php 
       // include('schaltSatze.php'); 

       $volleAnreihe = array('hat revealed Einzelheiten von sein balance sheet fuer', '$land tech Einstellung'); 
      ?> 


       <div id="geheime"> 
         <?php echo ($volleAnreihe[0]); ?> 
       </div><!-- geheime --> 


       <div id="ang"> 
        <center> 
         <?php echo ($volleAnreihe[0]); ?> 
        </center> 
       </div><!-- ang --> 


       <div id="kaste"> 
        <center> 
         <input type="text" style="color:#c90" id="neuSatz" name="neuSatz" onMouseOver="focus(this)" value="??"> 
        </center> 
       </div><!-- kaste --> 

       <div id="fichs"> 
        <center> 
         <input type="button" class="klKnopfR" value="fich's" onClick="stopfSelbe()"> 
        </center> 
       </div><!-- untwirf --> 

       <div id="schicks"> 
        <center> 
         <input type="button" class="klKnopfG" value="schick's"> 
        </center> 
       </div><!-- untwirf --> 

</div><!-- aaa --> 

<script> 
    function stopfSelbe(){ 

     var e = document.getElementById('geheime'); 
     var i = e.innerHTML; 
     var f = document.getElementById('neuSatz'); 

     f.value=i; 

     alert(i); 

     // document.write(i); 
    } 
</script> 
+2

它'知名度:hidden'風格 – odedta

+0

你能簡化你的[標籤:HTML]在通過在線演示[標籤:jsbin]或[標籤:的jsfiddle] – SaidbakR

+0

你的意思是文字有'知名度:隱藏'風格?我將如何改變這一點? – Hektor

回答

0

相當奇怪的是,我應該結束了回答有關計算器我第一次的問題,但萬一別人遇到了同樣的問題...

的原因是沒有顯示在文本框中起來是T之間的空白他的兩個div標籤被.innerHTML拾起,因此插入獲取的值後,文本框中出現了許多標籤/空格。而且我沒有注意到警報信息略有偏差。實際需要的值始終存在,但文本框太短而無法顯示。

一個更好的解決辦法是

  var e = document.getElementById('geheime'); 
      var i = e.innerHTML.trim();