title: Setting HTML select value using JavaScript
body: <p><b><code>index.php</code></b></p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  function setActionStar(btnValue) {
   var actionstar = document.getElementById('actionstars');
  
   alert(btnValue);
   alert(actionstar.value);
  
   actionstar.value = btnValue;
   return false;
  }
  &lt;/script&gt;
  
  &lt;form&gt; 
   &lt;?php
    $actionstars = array("Jean Claude Van Damme", "Scott Adkins", "Dolph Lundgren", "Michael Jai White");
  
    $ctr = 1;
   ?&gt;
  
   &lt;select id="actionstars" name="actionstars"&gt;
    &lt;?php
     foreach($actionstars as $as){
      echo "&lt;option value=" . $ctr . " &gt;" . $as . "&lt;/option&gt;";
      $ctr++;
     }
    ?&gt;
   &lt;/select&gt;
  
   &lt;br /&gt;
  
   &lt;?php
    for($i=1; $i&lt;= count($actionstars); $i++) {
   ?&gt;
   &lt;input type="submit" value="&lt;?php echo $i; ?&gt;" onclick="setActionStar(this.value);" /&gt;
   &lt;?php
    }
   ?&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>I've been dealing with this dilemma for almost 2 hours. I don't know what's wrong with this. What I'm trying to do is whenever the user clicks a button, it will change the combobox value to the value of the button. For example, if I hit button 1, the combobox will have the value 1. It's working with other HTML elements but I don't know why it's not applicable here.</p>
  
  <p>I am very new to programming so don't be harsh to me. Please don't think I didn't do an effort on this. It's just I don't know what I am doing honestly. Please help.</p>