2014-09-29 45 views
0

我想在下面的HTML中顯示變量fullScript
我試過了,但沒有奏效。
我在做什麼錯?HTML中的JQuery變量

JQUERY

 $(document).ready(function() { 
      var fullDate = new Date();console.log(fullDate); 
      var twoDigitMonth = fullDate.getMonth()+"";if(twoDigitMonth.length==1) twoDigitMonth="0" +twoDigitMonth; 
      var twoDigitDate = fullDate.getDate()+"";if(twoDigitDate.length==1) twoDigitDate="0" +twoDigitDate; 
      var currentDate = fullDate.getFullYear() +"-"+ twoDigitMonth + "-" + twoDigitDate; 
      var currentTime = fullDate.getHours() +":"+ fullDate.getMinutes() 
      console.log(currentDate); 
      console.log(currentTime); 


      var fullScript = "/opt/fings/interface/postEnginInstruction.py --call --viewdevicedata 130150000008 "+currentDate+" "+currentTime+" False"; 
      console.log(fullScript); 
      $('#fullScript').html(fullScript); 
     }); 

HTML

   <span> 
        <label for="fullScript" class="frm_label">Script to run</label> 
        <div class="frmFull"><input type="text" class="editBox readonly" id="fullScript" name="fullScript"/></div> 
       </span> 

PS - console.log(fullScript);正在顯示100%

回答

2

要改變一個輸入的值,使用val,不html

$('#fullScript').val(fullScript); 
+0

agghhh。是的,我應該知道。無論如何感謝你說明明顯。有時它確實有幫助 – morne 2014-09-29 09:54:42

1

您應該使用.val()而不是.html()設置變量input

更改此

$('#fullScript').html(fullScript); 

$('#fullScript').val(fullScript);