Find us on facebook

Aug 29, 2014

Vehicle Dropdown with images

html file
include_once $_SERVER['DOCUMENT_ROOT'].COMMON.'/js/js_homewaypoint.php';
<div id="vehicle"></div>

js_homewaypoint.php
<script src="scripts/jquery/autocompleteused/jquery-ui.min.js"></script>

<script src="scripts/ddslickvehicles/jquery.ddslick.js"></script>
<?php
$vehicleArray = $objaVehiclesTbl->getVehiclesAll();
while($vehicleRow = mysql_fetch_array($vehicleArray)):
    $imageName = $vehicleRow['image'];
    $imageSrc = "images/$imageName";
    $vehicleData[] = array(
'text' => ucwords(strtolower($vehicleRow['name'])),
'value' => (int)$vehicleRow['id'],
                        'description' => $vehicleRow['desc'],
                        'imageSrc' => $imageSrc
);
endwhile;


$vehicleDataJason = json_encode($vehicleData);

?>

<script language="javascript">
   
$(document).ready(function()
{
$('#vehicle').ddslick({
data: <?php echo $vehicleDataJason; ?>,
width: 289,
imagePosition: "left",
selectText: "Select Vehicle",
onSelected: function (data) {
  console.log(data);
$("#vehicle_way_one_index").val(data.selectedIndex);
$("#vehicle_way_one").val(data.selectedData.value);
$('#vehicle-return').ddslick('select', {index: data.selectedIndex });
if(data.selectedData.value != ''){
$('#vehicle_error').hide();
}
}
});
});
</script>

No comments:

Post a Comment