title: Adding Attributes to Select Options in Joomla
body: <p>I'm trying to add extra HTML attributes to some select options in a dropdown list in Joomla 2.5, and want to use the built-in HTML helpers rather than write the HTML by myself. The current output is:</p>
  
  <pre><code>&lt;select&gt;
      &lt;option value="Red"&gt;Red&lt;/option&gt;
  &lt;/select&gt;
  </code></pre>
  
  <p>but I would like it to be something like:</p>
  
  <pre><code>&lt;select&gt;
      &lt;option value="Red" data-img="red.jpg"&gt;Red&lt;/option&gt;
  &lt;/select&gt;
  </code></pre>
  
  <p>so that I can access the data-img attribute using Javascript when the selected option changes.</p>
  
  <p>I'm creating the select options like so:</p>
  
  <pre><code>$select = JHtml::_('select.option', "Red", "Red");
  </code></pre>
  
  <p>and then passing them to JHTML to create the generic list HTML:</p>
  
  <pre><code>$html = JHTML::_('select.genericlist', ...);
  </code></pre>
  
  <p>I've looked through the documentation and tried passing various different parameter to the functions, but it's very confusing in terms of all the options (<code>option.attr</code>, <code>attr</code> etc) that the functions use, and Google has turned up nothing either.</p>
  
  <p>Can anyone tell me what extra parameters I need to pass to the functions to get it properly add the extra attributes to the <code>&lt;option&gt;</code> elements?</p>
  
  <p>Thanks in advance!</p>