php - SyntaxError: expected expression, got '<' JQuery -


<script>  $(document).ready(function(){      $(function() {         $("#country").val("<?php echo $_session['country'];?>");      }); })   

<td>country:</td> <td colspan="2"><select name="country" id="country">     <option value="93">93-afghanistan</option>     <option value="355">355-albania</option>     <option value="213">213-algeria</option>     <option value="1-684">1-684-american samoa</option>     <option value="376">376-andorra</option></td> 

i trying select drop-down list based on users selection. code given 1 of current user there syntax-error occur. can solve this?

the best solution problem go thrrough appropiate selection , below -

$(document).ready(function(){  var v="<?php echo $_session['country'];?>";  $('#country option[value='+v+']').attr('selected', 'selected'); }) ;  

and unnecessarily using

$(document).ready(function(){} , $(function() {}); equivalent.. use either 1 of them

live http://jsfiddle.net/mailmerohit5/ndxzpo3c/


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -