Setting value of Select in html
<p>I am generating this html from python and 2% is the value of the field so it is what should be shown but I am baffled as to why it doesn't work as I expect. I have tried so many permutations and figure it is something so simple.   Please Help.  I don't necessarily want to use the selected option in the <code>&lt;option&gt;</code> tag.</p>

<pre><code>    &lt;select name="discount" value="2%"&gt;
       &lt;option&gt;10%&lt;/option&gt;
       &lt;option&gt;9%&lt;/option&gt;
       &lt;option&gt;8%&lt;/option&gt;
       &lt;option&gt;7%&lt;/option&gt;
       &lt;option&gt;6%&lt;/option&gt;
       &lt;option&gt;5%&lt;/option&gt;
       &lt;option&gt;4%&lt;/option&gt;
       &lt;option&gt;3%&lt;/option&gt;
       &lt;option&gt;2%&lt;/option&gt;
       &lt;option&gt;1%&lt;/option&gt;
       &lt;option"&gt;0%&lt;/option&gt;
    &lt;/select&gt;
</code></pre>

<p>Add a selected attribute to the item. You also had a stray quotation mark on the last <code>&lt;option&gt;</code></p>

<pre><code>&lt;select name="discount"&gt;
    &lt;option&gt;10%&lt;/option&gt;
    &lt;option&gt;9%&lt;/option&gt;
    &lt;option&gt;8%&lt;/option&gt;
    &lt;option&gt;7%&lt;/option&gt;
    &lt;option&gt;6%&lt;/option&gt;
    &lt;option&gt;5%&lt;/option&gt;
    &lt;option&gt;4%&lt;/option&gt;
    &lt;option&gt;3%&lt;/option&gt;
    &lt;option selected&gt;2%&lt;/option&gt;
    &lt;option&gt;1%&lt;/option&gt;
    &lt;option&gt;0%&lt;/option&gt;
&lt;/select&gt;
</code></pre>

<p><strong>Alternatively you can use JavaScript to set the option:</strong></p>

<pre><code>document.getElementsByName('discount')[0].selectedIndex = 8
</code></pre>

<p><strong>or as you've suggested in the comments if all values are unique you may be able to just set the value</strong> the only caveat to this method is if two options have the same value but different text the incorrect option may be selected</p>

<pre><code>document.getElementsByName('discount')[0].value = "2%"
</code></pre>

<p>Either of these scripts should be able to be run inlined anywhere after the select box or onload.</p>

python html