title: Selecting default value in html dropdown list
body: <p>I am currently looking to have a drop down list in my form. I have this drop down which selects the default value:</p>
  
  <pre><code>&lt;p&gt;Price Band:&lt;select id='priceBand' style = 'width:150px' value = 'band1'&gt;
  &lt;option value="band7"&gt;Reduce by 30c&lt;/option&gt;
  &lt;option value="band6"&gt;Reduce by 25c&lt;/option&gt;
  &lt;option value="band5"&gt;Reduce by 20c&lt;/option&gt;
  &lt;option value="band4"&gt;Reduce by 15c&lt;/option&gt;
  &lt;option value="band3"&gt;Reduce by 10c&lt;/option&gt;
  &lt;option value="band2"&gt;Reduce by 5c&lt;/option&gt;
  &lt;option value="band1"  selected="selected"&gt;default&lt;/option&gt;
  &lt;/select&gt;&lt;/p&gt;
  </code></pre>
  
  <p>Which works fine and selects the default as the default value. But what I also need to be able to do - after the form is submitted I want it to keep the last selected value as the default one. It is a form used to add sales with different price bands. The sales are entered by the price bands so the defaults are entered first, the band2, band3 and so on.. What is the best way of doing it? I am currently using javascript and php on the page if that makes it any easier?</p>
  
  <p>Ajax code. I didn't include getting the value of the dropdown as this is only a new thing that I am implementing. I just want to know if it is possible to have a default value selected when the form is loaded first and then when a different value is selected, to keep that value as the new default:</p>
  
  <pre><code> $('#divItemisedSaleAdd').dialog({'autoOpen': false, 'modal' : true, 'buttons' : 
       [ { text: "Ok", click: function() {
          var url = '&lt;?php echo Navigation::gUrl('/users/admin/stocktake_details_sales.php', array('stocktake_id' =&gt; $stocktake_id, 'action' =&gt; 'add_itemised_sale'));?&gt;';
  
          var productCode = $('#ProductCode').val();
          var qty = $('#Quantity').val();
  
          var dialog = this;
  
          $.ajax({
              url: url,
              dataType: 'json',
              data: {'productCode' : productCode, 'qty' : qty},
              type: 'post',
              timeout: 5000,
              success: function(json) { 
                  if (json.status == 'S'){
                      alert('Sale added'); 
                  }
                  else if (json.status == 'E')
                      alert('No product with given PLU was found! Please check!');
                      // loadDepartments();
                      $( dialog ).dialog( "close" );
  
              },
               error: function() {}
  
           });    
  
  
            } } ] });
  </code></pre>