title: Compare key value array in ejs to combo selected value
body: <p>I have a route js where I define get function like this:</p>
  
  <pre><code>exports.get = function (req, res) {
  var calls = [{
  
      propertyTypes: function (acc) {
          return '/catalog/propertyTypes/';
  
      },
  
  }];
  
      commercial_residential = {
          1 : 'Residencial',
          2 : 'Comercial'
      }
  
      property_types = [
          [
              [4  , "departamento"],
              [5  , "campo"],
              [8  , "casa"],
              [13 , "duplex"],
              [43 , "casa"],
              [47 , "departamento"],
              [49 , "campo"],
              [50 , "Terreno"],
              [53 , "departamento"],
              [63 , "ph"]
          ],[
              [1  , "Local"],
              [2  , "Quinta"],
              [3  , "Cochera"],
              [4  , "Galpon"],
              [5  , "emprendimiento"],
              [6  , "Lote"],
              [7  , "Oficina"],
              [9  , "Fondo de Comercio"],
              [10 , "Galpon"],
              [12 , "fondo de comercio"],
              [13 , "fondo de comercio"],
              [79 , "fondo de comercio"]
          ]
      ]
  
  fetcher.getWithDependencies(calls, function (err, results) {
      var propertyTypes = (results.propertyTypes) ? results.propertyTypes : [];
  [];
  
      fetcher.get('/ilist/importer/get/property/' + id, function (e, results) {
          res.render('ilist-importer/property', {
              'data': results,
              'list': {
                  'propertyQR': propertyTypes,
                  'propertyTypes': property_types,
              }
          });
      });
  })
  };
  </code></pre>
  
  <p>In my form for this get function, in ejs file I have a combo where I display all <code>property_types</code> names. When forms submit I need to compare that selected value property_type name with key value array <code>propertyQR</code> that comes from route.js.
  Here's my form select:</p>
  
  <pre><code>   &lt;select name="comercial" id="comercial_form" class="span3"&gt;
                &lt;option value="0"&gt;-Seleccione-&lt;/option&gt;
                  &lt;% for(var i=0; i &lt; list.propertyTypes[1].length; i++) { %&gt;                            
                     &lt;option value="&lt;%= list.propertyTypes[1][i][1] %&gt;"&gt;                          
                       &lt;%= list.propertyTypes[1][i][1] %&gt;
                &lt;/option&gt;
                      &lt;% } %&gt;
                  &lt;/select&gt;
  </code></pre>
  
  <p>Here's what I have so far. First I try to copy PropertyQR array that I get from route.js into a new array PropertyTypeID, and then when form submits I compare selected value in form with the key value array name field that I created and get id field if it matches. </p>
  
  <pre><code>  &lt;script&gt;
  
          $(function () {
    var propertyTypeID = [];
  
    for(var i=0; i&lt; &lt;%= list.propertyQR.length%&gt;; i++){
  
              propertyTypeID.id.push(&lt;%= list.propertyQR[i].id %&gt;)
  
              propertyTypeID.name.push(&lt;%= list.propertyQR[i].name %&gt;)
  
              };
  
   $('#submit-import-form').click(function(){
      for(var i=0; i &lt; propertyTypeID.length; i++){
  
                  if (tipoPropiedad==propertyTypeID[i].name)
  
                      propertyTID=propertyTypeId[i].id;
  
                  }
  }
    });
  
      &lt;/script&gt;
  </code></pre>
  
  <p>Now, when I try to load the form I get:</p>
  
  <blockquote>
    <p>Uncaught TypeError: Cannot read property 'push' of undefined</p>
  </blockquote>
  
  <p>Why is this happening? Please help!!!!!</p>