title: How to store a value from jsp select tag into input tag
body: <p>I am trying to store a text value into an input tag from two select tags, where the value of second select tag depends on the first one. There's a javascript running for this , which looks something like this:</p>
  
  <pre><code>  &lt;script&gt;
    function byId(e) {return document.getElementById(e);}
  
    function categoryComboChange()
    {
    var combo1 = byId('categoryCombo');
   var combo2 = byId('subcategoryCombo');
   alert(combo1.value);
  
  emptyCombo(combo2);
  switch(combo1.value)
  {
      case '-1':  addOption(combo2, -1, '-select category first-');
                  break;
      case '0':   addOption(combo2,0,'Nokia');
                  addOption(combo2, 1, 'Samsung');
                  addOption(combo2, 2, 'Sony');
                  addOption(combo2, 3, 'Iphone 5');
                  addOption(combo2, 4, 'Lava');
                  addOption(combo2, 5, 'Micromax');
  
                  break;
      case '1':   addOption(combo2, 2, 'Edge Router');
                  addOption(combo2, 3, 'Subscriber Edge Router');
                  addOption(combo2, 4, 'Inter-provider Border Router');
                  addOption(combo2, 5, 'Core Router');
                  addOption(combo2, 6, 'Wired and Wireless Routers');
  
                  break;
      case '2':       addOption(combo2, 4, 'MTS');
                  addOption(combo2, 5, 'Docomo');
                  addOption(combo2, 5, 'Airtel');
                  addOption(combo2, 5, 'Photon');
                  addOption(combo2, 5, 'Idea');
                  addOption(combo2, 5, 'Vodafone');
  
                  break;
      }
    subcategoryComboChange();
        }
  
     function subcategoryComboChange()
        {
  
    var Category = document.getElementById('subcategoryCombo').value;
  
  
  
  
  
  
  
  // Used desired display of following commands 
  
  document.getElementById('cvalue').value = Category;
  
  
  
  
  
       }
  
        function emptyCombo(e)
        {
     e.innerHTML = '';
         }
  
        function addOption(combo, val, txt)
           {
    var option = document.createElement('option');
    option.value = val;
    option.title = txt;
    option.appendChild(document.createTextNode(txt));
     combo.appendChild(option);
     }
  
    &lt;/script&gt;
  </code></pre>
  
  <p>and my jsp page with required elements looks like this:</p>
  
  <pre><code>        &lt;div class="element"&gt;
                      &lt;label for="category"&gt;Category &lt;/label&gt;
                      &lt;select id='categoryCombo'             onchange='categoryComboChange();'&gt;
      &lt;option value='-1' title='-select one-'&gt;-select one-&lt;/option&gt;
      &lt;option value='0' title='Mobile'&gt;Mobile&lt;/option&gt;
      &lt;option value='1' title='Nsw'&gt;Routers&lt;/option&gt;
      &lt;option value='2' title='Tas'&gt;Datacard&lt;/option&gt;
  &lt;/select&gt;
                                          &lt;/div&gt;
  
                  &lt;div class="element"&gt;
                      &lt;label for="category"&gt;Sub-Category &lt;/label&gt;
                       &lt;select id='subcategoryCombo' name="category" onchange='subcategoryComboChange();'&gt;
      &lt;option value='-1' title='-select category first-'&gt;-select category first-&lt;/option&gt;
  &lt;/select&gt;
                  &lt;/div&gt;
  
  
                    &lt;div class="element"&gt;
                  &lt;input id="cvalue" name="cval" class="text err" /&gt;
  
                          &lt;/div&gt;                      
  </code></pre>
  
  <p>Currently, I am able to get the value in form of number like 0,1,2, depending on the choice, but I need to show text value in the input tag, like say for Mobile, it should show either nokia, samsung, etc.  Can anyone suggest where I need to change my code in order to implement this task?</p>