Remember the selected value once refreshed the page
<p>In a page containing a form with select fields, I need to remember the previuos choice (if any) of, for example, the selected state. I want to do it via PHP embedded in JS, where I'm wrong?</p>

<pre><code>&lt;script&gt;
&lt;?php
if(isset( $_GET["state"] )){
$selected_state =  $_GET["state"];
?&gt;
$("#state option[&lt;?php echo $selected_state ?&gt;]").attr("selected", "selected");
&lt;?php } ?&gt;
&lt;/script&gt;
</code></pre>

<p>Thank you in advance!</p>
