Skip to content

Instantly share code, notes, and snippets.

@wihodges
wihodges / JS Param GET
Created April 26, 2012 19:20
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"));
@wihodges
wihodges / Auto Param Push
Created April 26, 2012 19:17
Append all urls with current page URL parameters - JS
$(document).ready(function(){
elements = $('.openURL');
passMe = window.location.href.slice(window.location.href.indexOf('?'));
elements.each(function() {
url = $(this).attr("href");
newURL = url + passMe;
$(this).attr("href", newURL);
});
});