我有这个片段
<script>
function redirect($i){
$(function(){
var trans = $('#trans'+$i).html();
var mileage = $('#mileage'+$i).html();
var eng = $('#eng'+$i).html();
var ext = $('#ext'+$i).html();
var stock = $('#stock'+$i).html();
var vin = $('#vin'+$i).html();
var location = $('#location'+$i).html();
var price = $('#price'+$i).html();
var photo = $('#photo'+$i).attr('src');
window.location.href = "details.php?trans="+trans+"&&mileage="+mileage+"&&eng="+eng+"&&ext="+ext+"&&stock="+stock+"&&vin="+vin+"&&location="+location+"&&price=$$"+price+"&&photo="+photo;
});
</script>
<?php
include('function.php');
$Descriptions = Descriptions();
?>
<!--vehicle1-->
<?php
for($i=0;$i<sizeof($Descriptions);$i++){
?>
<div class="vehicle-listing alternate">
<div class="vehicle-title-wrap"><h6><a ><?php $Descriptions[$i]['ad_title']; ?></a></h6></div>
<div class="vehicle-inner-wrap">
<div class="vehicle-photo" id="thumb_holder_1">
<a ><img id="photo"+"<?php echo $i;?>" src="<?php $id=$Descriptions[$i]['id'];$Images = Images($id); echo $Images[0]['imagepath']; ?>" class="thumbnail lazy-load" width="170px" height="140px" /></a>
</div>
<a >
<div class="click-to-view" OnClick="redirect(<?php echo $i; ?>)" ></div>
</a>
<div class="first-half vehicle-specs container">
<div class="container"><span class="spec-label">Trans:</span> <span class="spec-data" id="trans"+"<?php echo $i;?>"><?php echo $Descriptions[$i]['trans']; ?></span></div>
<div class="container"><span class="spec-label">Mileage:</span> <span class="spec-data" id="mileage"+"<?php echo $i;?>" ><?php echo $Descriptions[$i]['mileage']; ?></span></div>
<div class="container"><span class="spec-label">EXT:</span> <span class="spec-data" id="eng"+"<?php echo $i;?>" ><?php echo $Descriptions[$i]['engine']; ?></span></div>
</div>
<div class="second-half vehicle-specs container">
<div class="container"><span class="spec-label">Ext Color:</span> <span class="spec-data" id="ext"+"<?php echo $i;?>"><?php echo $Descriptions[$i]['color']; ?></span></div>
<div class="container"><span class="spec-label">Stock :</span> <span class="spec-data" id="stock"+"<?php echo $i;?>"><?php echo $Descriptions[$i]['stock']; ?></span></div>
<div class="container"><span class="spec-label">VIN :</span> <span class="spec-data" id="vin"+"<?php echo $i;?>"><?php echo $Descriptions[$i]['vin']; ?></span></div>
</div>
<div class="location">
<span class="lake-worth" >Location: <span id="location"+"<?php echo $i;?>" ><?php echo $Descriptions[$i]['state']; ?></span></span>
<span class="lake-worth">Price: $$<span id="price"+"<?php echo $i;?>" >
<?php echo $Descriptions[$i]['price']; ?></span></span>
</div>
</div>
</div>
<?php
}
?>
问题是重定向后的值未定义。我认为问题在于字符串(jquery 或 html)的连接。因此,重定向中的值是错误的。
- 任何人都可以显示错误在哪里吗?
- 我该如何解决?