title: How can I get a Javascript Select Option Value to be Submitted to the database by Post
body: <p>This is My form fields Object that create the form element with its attributes. I am trying to get the select option values from the form by document.getElementById() method as shown below <strong>without using JQuery</strong></p>
  
  <pre><code>var model = vehicle.extend(vehicle.compare, {
  
  fromFields:[{
      id: 'vehicle',
      label: 'Vehicle',
      name: 'vehicle',
      type: 'select',
      options: [
          {label: 'KBS999H', value:'BU'}, 
          {label: 'KBB343T', value:'LO'}, 
          {label: 'KBD342H', value:'YU'}
       ]
  },{
      id: 'modelId',
      label: 'Vehicle Model',
      name: 'model',
      type: 'select',
      options: [
          {label: 'TOYOTA', value:'TT'}, 
          {label: 'VOXY', value:'VO'}, 
          {label: 'MISTUBISHI', value:'MIST'},
          {label: 'SUBARU', value:'SU'}
       ]
  },{
      id: 'price',
      label: 'Price',
      name: 'price',
      type: 'number'
  }]
  
  });
  </code></pre>
  
  <p><strong>this is the part of the framework i am trying to submit the form</strong></p>
  
  <pre><code>    submitForm: function(){
      var me = this;
  
      var formValues = me.fromFields.filter(function(el){
  
          if (el.type == 'select' &amp;&amp; el.options){
              //to get the selected value 
              var select = document.getElementById(el.options[name]).value;
  
          console.log(me.fromFields.id);
  
          }
  
          var formEl = me.getEl(el.id);
          if(formEl &amp;&amp; formEl.value)
              return el;
  
      }).map(function(el){
          var formEl = me.getEl(el.id);
          return encodeURIComponent(el.name) + '=' 
              + encodeURIComponent(formEl.value);
  
      }).join('&amp;');
  
      me.ajaxRequest.call({
          httpMethod: 'POST',
          httpUrl: me.formUrl,
          requestParams: formValues,
          responseTarget: me.responseTarget,
          updateTarget: function(resp){
              if(me.aftersubmit)
                  me.aftersubmit();
          }
      });
  
  }
  </code></pre>
  
  <p><strong>Encountered Error</strong></p>
  
  <blockquote>
    <p>TypeError: document.getElementById(...) is null</p>
    
    <p>var select = document.getElementById(el.options[name]).value;</p>
  </blockquote>