get a php variable in java script function : <p>i have this dropdown list  and i need to save it's value by javascript but i can't get the name of the php variable (select name ) into the function</p>

<p>drop down list :</p>

<pre><code>   $i=0;
   while($i&lt;$counter)
        {
      $vname=$row['student_id'].'_'.$i;
        echo"
          &lt;td&gt;

            &lt;select name=".$vname."&gt;
  &lt;option value="."0"."&gt;Choose one&lt;/option&gt;
 &lt;option value="."1"."&gt;Add&lt;/option&gt;
 &lt;option value="."2"."&gt;R&lt;/option&gt;
 &lt;option value="."3"."&gt;TBR&lt;/option&gt;
 &lt;option value="."4"."&gt;P&lt;/option&gt;
      &lt;/select&gt;
   &lt;/td&gt;";
       $i++;
            }
</code></pre>

<p>java script function :</p>

<pre><code>           &lt;script src="https://code.jquery.com/jquery-1.9.1.min.js"&gt;&lt;/script&gt;                               
                     &lt;script&gt;
                 $(document).ready(function() {

             var item = window.localStorage.getItem('".$vname."');
              $('select[name=".$vname."]').val(item);

           $('select[name=".$vname."]').change(function() {
                 window.localStorage.setItem('".$vname."', $(this).val());
                 });

               });  
            &lt;/script&gt;
</code></pre>
