PHP/ Jquery Dropdown Select


/ Published in: jQuery
Save to your folder(s)

Set a variable by getting the URLs id with PHP. Find the the option with the name value that is equal with the variable and add "selected" to it.


Copy this code and paste it in your HTML
  1. var pId = "<? echo $_GET['category'] ?>";
  2. $("select#category option[name=" + pId + "]").prop("selected", true);

Report this snippet


Comments


You need to login to view comments.