我想将用户在表单字段中输入的值从被叫fare传递到另一个页面,在javascript中有一个名为fare1的不同表单
Form1中:
<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>
答案 0 :(得分: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>
答案 1 :(得分:0)
如果您的票价表单处理程序引用了fare1页面,那么可以通过查询字符串传递值,并在fare1中将它们删除。