如何将浮点值传递给另一页?我已经在AJAX请求中发送了浮点值,但是页面仅接收到整数值。

<div class="form-group">
  <label for="" class="col-sm-4 control-label">Pole to Pole distance in feets <font color="red">*</font></label>
  <div class="col-sm-6">
    <input type='number' class="form-control" name='ppdistance' id="ppdistance" placeholder="Pole to Pole distance in feets" required="required" min="0">
  </div>
</div>
<br>
<div class="form-group">
  <label for="" class="col-sm-4 control-label">Number of Fencing line per Pole <font color="red">*</font></label>
  <div class="col-sm-6">
    <input type="number" class="form-control" name='fensing' id="fensing" placeholder="Number of Fencing line per pole " required="" step="0.01">
  </div>
</div>
<br>
<div class="modal-footer">
  <input type='button' id="myBtn" class="btn btn-default btn1" value="Submit">
</div>


document.getElementById("myBtn").addEventListener("click", myFunction);

function myFunction() {
  let data = {
    size: $('[name="size"]').val(),
    numpols: $('[name="numpols"]').val(),
    ppdistance: $('[name="ppdistance"]').val(),
    fensing: $('[name="fensing"]').val()
  }
  alert(data);

  $.ajax({
    type: "POST",
    url: "joins.php", //"join.php"
    dataType: "html",
    data: data,
    success: function(response) {
      document.getElementById('demo').innerHTML = response;
    },
    error: function(error) {
      alert(error)
    }
  });


检索页面值可以打印整数值显示

echo $numpols;
echo '<br>';
echo $ppdistance;
echo '<br>';
echo $fensing;
echo '<br>';

echo $ms = $numpols * $ppdistance * $fensing;


我得到的输出看起来像这样:

670
7
78
365820


我期望我的输出看起来像这样:

670
7
7.8
36582


我怎样才能解决这个问题?
您还可以看到屏幕快照吗javascript - 如何将浮点值输入类型传递给另一页以进行检索-LMLPHP

最佳答案

只需添加

<input type='number' class="form-control" name='ppdistance' id="ppdistance" placeholder="Pole to Pole distance in feets" required="required" min="0">


min =“ 0”值,请刷新浏览器并进行设置

09-25 18:41