Problems creating url with query string

Problems creating url with query string

Hi all,

I'm tring to create a url with query string data using a form with multiple dropdown options.

I'm using the first dropdown to select the url and the second dropdown to add the query string to the selected url. The change method updates variable values and the click event merges those variables to form the url. The problem is that I can't seem to tag anything onto the end of the url. I've read about using the $.param function but I have yet to find an example where the output is appended to the end of a url. 

Here is my html form and jquery:
  1. <form id="myForm" method="GET">
  2. <select id="url-select">
  3.     <option value="select">Select Page</option>
  4.     <option value="example-1.php">Industry 1</option>
  5.         <option value="example-2.php">Industry 2</option>
  6.     </select>
  7.     <select id="query-select">
  8.     <option value="select">Select Tab</option>
  9.     <option value="query1">Query One</option>
  10.         <option value="query2">Query Two</option>
  11.         <option value="query3">Query Three</option>
  12.     </select>
  13. <button id="submit">Submit</button>
  14. </form>

  15. $(function() {
  16. var urlSelect = null;
  17. var querySelect = null;
  18. var url = null
  19. $("#url-select").change(function() {
  20. urlSelect = $("#url-select").val();
  21. });
  22. $("#query-select").change(function() {
  23. querySelect = $("#query-select").val();
  24. });
  25. $("#submit").click(function() {
  26. url = urlSelect + querySelect;
  27. $("#myForm").attr("action", url);
  28. });
  29. });