私はこのスニペットを持っています
<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)の連結にあると思います。このため、リダイレクトの値は false です。
- エラーの場所を教えてください。
- どうすれば修正できますか?