0

I'm not sure is it possible but I need something like this

  1. pass argument to my html file (e.g a.html?status=failed)
  2. somehow process this value by jquery to change select value
Gayane
  • 627
  • 1
  • 11
  • 23
  • 1
    Like this: http://jquery-howto.blogspot.nl/2009/09/get-url-parameters-values-with-jquery.html – Biketire Dec 06 '13 at 12:11
  • Try this way : http://stackoverflow.com/questions/7808402/dynamic-default-selection-for-a-drop-down-menu-using-url-variables – Ankit Tyagi Dec 06 '13 at 12:12

1 Answers1

0

Using URL Parser jQuery plugin

$(document).ready(function(){
 var valuePassed=$.url().param('status');

 $('#select').val(valuePassed);

});

or with vannila javascript helper function explained in How can I get query string values in JavaScript?

function getParameterByName(name) {
    name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
    var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
        results = regex.exec(location.search);
    return results == null ? "" : 
                 decodeURIComponent(results[1].replace(/\+/g, " "));
}

$(document).ready(function(){
  var valuePassed=getParameterByName('status');

  $('#select').val(valuePassed);

});
Community
  • 1
  • 1
Murali Murugesan
  • 22,423
  • 17
  • 73
  • 120