0

我想将用户在表单字段中输入的值从被调用的票价传递到不同的页面,在 javascript 中有一个不同的表单,称为 fare1

表格1:

<form action="/estimate-fare" name="fare" method="link" enctype="multipart/form-data">   
  <div class="pickupaddressWrapper">
    <label for="pickupaddress">Pickup Address: <span class="form-required" title="This  field is required.">*</span></label>
    <input type="text" maxlength="128" name="pickupaddress" id="pickupaddress" size="30"  value="" class="form-text required" />
  </div>

  <div class="dropoffaddressWrapper">
    <label for="dropoffaddress">Dropoff Address: <span class="form-required" title="This field is required.">*</span></label>
    <input type="text" maxlength="128" name="dropoffaddress" id="dropoffaddress" size="30" value="" class="form-text required" />
  </div>
  <input type="submit"  id="edit-submit" value="" class="form-submit" /> 
</form>
4

2 回答 2

1

在玩了之后,它击中了我......为什么不通过另一种形式传递值?不涉及查询字符串,所有内容都在 $_POST 数据中传递。

/estimate-fare/index.php

<?php 
$pickupat = $_POST['pickupaddress'];
$dropoffat = $_POST['dropoffaddress'];
$distance = calcDistance($pickupat,$dropoffat); // the function that calculates or looks up distance between points - (float) miles
$time = calcTime($pickupat,$dropoffat); // function to calculate time taken at present time of day - (int) minutes
$fare1 = $distance * 10 * $distancerate; // meter rate per 10th of a mile
$fare2 = $time * $timerate; // meter rate per minute
$estfare = ($fare1 > $fare2) ? $fare1 : $fare2;
?>
<html>
<body>
 ...
 <form method="post" action="summary.php">
 <input type="text" value="<?php echo $pickupat; ?>">
 <input type="text" value="<?php echo $dropoffat; ?>">
 <input type="text" value="<?php echo $distance; ?> Miles">
 <input type="text" value="<?php echo $time; ?> Minutes">
 <input type="text" value="<?php echo $estfare; ?>">
 <input type="submit" value="Next">
 </form>
 ...
 </body>
 </html>
于 2012-06-05T23:30:38.940 回答
0

如果您的票价表单处理程序引用 fare1 页面,则可以通过查询字符串传递值并将它们保存在 fare1 中。

于 2012-06-05T01:01:02.003 回答