Skip to content

Instantly share code, notes, and snippets.

@wihodges
Created April 26, 2012 19:20
Show Gist options
  • Save wihodges/2502249 to your computer and use it in GitHub Desktop.
Save wihodges/2502249 to your computer and use it in GitHub Desktop.
JS get param and print into form value
$(document).ready(function (){
$.urlParam = function(name){
var results = new RegExp('[\\?&]' + name + '=([^&#]*)').exec(window.location.href);
if (results==null){return null;}
else{return results[1] || 0;}
}
console.log($.urlParam('seng'));
$('#locationtoprint').attr('value', $.urlParam("param1"));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment