输入

时间:2016-06-02 17:07:41

标签: javascript

我有表单转换,我需要根据用户在实时中输入的数量更新结果。

但结果总是一样的。 我认为问题在于可变价格,这不是用最后写入的输入数量更新的。

这是表格

<input type="text" id="from_amount" value="0" name="amount" /> 
<span class="num" id="conv_result">0</span>
<input type="submit" action="" method="" >  

这是javascript

function a(){

var price = $("#from_amount").val(); //Get the number of the input

if (price == 0){
        var total = 1;
    }else if (price > 20 && price < 30){
        var total = price * 2;
    }else{ 
        var total = 4;
}
     return total;
}

  var conver = {
     'people': {
     'rooms': a() 
      },
  };

0 个答案:

没有答案