Advertisement
Kaidul

Script

Nov 24th, 2012
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.89 KB | None | 0 0
  1. <script type="text/javascript">
  2.       $(document).ready(function(){
  3.         <? echo "var ID = $jsid;" ?>
  4.         var url = "inventory/inventory.json";
  5.         function addCommas(str) {
  6.              var amount = new String(str);
  7.              amount = amount.split("").reverse();
  8.              var output = "";
  9.              for ( var i = 0; i <= amount.length-1; i++ ){
  10.              output = amount[i] + output;
  11.              if ((i+1) % 3 == 0 && (amount.length-1) !== i) output = ',' + output;
  12.              }
  13.              return output;
  14.         }        
  15.        
  16.         $.getJSON(url, function(data){
  17.             $.each(data, function(index, item){
  18.                 if(item.id === ID) {
  19.                     $('#car_heading').html(item.year + ' ' + item.make + ' ' + item.model);
  20.                     var Details = new Array(item.make, item.model, item.year, item.vin, item.stock, item.body, item.mpg, item.color.ext, item.color.int, item.trim, item.power.drive, item.power.trans, item.power.eng);
  21.                     var tr = $("#cardetails tr");
  22.                     tr.each(function(){
  23.                         $(this).children('td:nth-child(2)').html(Details[$(this).index()]);
  24.                     });
  25.                     return false;
  26.                 }  
  27.             });  
  28.         });
  29.       });
  30. </script>
  31.  
  32.     <div>
  33.         <table id="cardetails">
  34.             <tbody>
  35.                <?php
  36.                  $itemArray = array("Make", "Model", "Year", "Vin Number", "Stock Number", "Body Style", "Ext. Color", "Int. Color", "Trim", "Drive Train", "Trans. Type", "Eng. Displacement");
  37.                  for ($i=0; $i < sizeof($itemArray); $i++) {
  38.                     ?>
  39.                     <tr>
  40.                         <td id="right"><?=$itemArray[$i].": "?></td>
  41.                         <td id="left"></td>
  42.                     </tr>                      
  43.                     <?
  44.                  }
  45.                ?>      
  46.             </tbody>
  47.         </table>
  48.     </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement