2017-09-28 54 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