Select form option on page load
<p>I would like to select the option contained within a php variable on page load.</p>

<pre><code>&lt;?php
$pre = 78;
?&gt;

&lt;select id="form8" name="form8"&gt;
&lt;option value="15"&gt;15&lt;/option&gt;
&lt;option value="25"&gt;25&lt;/option&gt;
&lt;option value="64"&gt;64&lt;/option&gt;
&lt;option value="78"&gt;78&lt;/option&gt;
&lt;option value="82"&gt;82&lt;/option&gt;
&lt;/select&gt;

&lt;script&gt;
$(document).ready(function(){
$("form8").val("&lt;?php echo $pre; ?&gt;");
}
&lt;/script&gt;
</code></pre>

<p>Expected output should be, </p>

<pre><code>&lt;select id="form8" name="form8"&gt;
&lt;option value="15"&gt;15&lt;/option&gt;
&lt;option value="25"&gt;25&lt;/option&gt;
&lt;option value="64"&gt;64&lt;/option&gt;
&lt;option value="78" selected="selected"&gt;78&lt;/option&gt;
&lt;option value="82"&gt;82&lt;/option&gt;
&lt;/select&gt;
</code></pre>

<p><a href="http://jsfiddle.net/qQZVN/1/" rel="nofollow">http://jsfiddle.net/qQZVN/1/</a></p>
