2017-09-28 69 views
1

我編寫了一個程序,用於在用戶在文本框中輸入值時更改字段的值。在我的情況下,2個文本框是高度和寬度。當有人輸入高度和寬度時,應顯示相關價格。我會把我的編碼放在下面。根據文本框更改更新字段jQuery

<div class="form-group"> 
     <div class="col-sm-9"> 
      <input type="text" id="height" /> 
      <input type="text" id="width" /> 


      <button type="button" id="show">Enter Size</button> 
<button type="button" id="hide">Hide</button> 

<script> jQuery('height').on('input', function() { 
    <?php echo "hello" ?> 


}); 

function() 
{ 
    <input id="post_price" type="hidden" name="price" value="<?=$price['price'];?>"> 
} 
</script> 

     </div> 
     </div> 

我不太確定我做的方式。目前沒有輸出結果。有人能幫助我嗎?爲了更有意義,我會附上我的表單的截圖。謝謝! enter image description here

回答

1

您可以使用​​或keypress事件。我做了一個小例子here