Created
February 9, 2015 21:06
-
-
Save goldhand/92c7cab5530c112baa2c to your computer and use it in GitHub Desktop.
Selects a color based on "color" query
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
(function(){ | |
function getQueryString() { | |
var queryString= []; | |
var hash; | |
var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&'); | |
for(var i = 0; i < hashes.length; i++) | |
{ | |
hash = hashes[i].split('='); | |
queryString.push(hash[0]); | |
queryString[hash[0]] = hash[1]; | |
} | |
return queryString; | |
}; | |
$(function(){ | |
var q = getQueryString(); | |
var selector = $("select")[0] | |
if(q && q['color']) { | |
$(selector).val(q['color']); | |
}; | |
}); | |
})(); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment