Skip to content

Instantly share code, notes, and snippets.

@haydenmuhl
Created August 28, 2011 14:37
Show Gist options
  • Save haydenmuhl/1176742 to your computer and use it in GitHub Desktop.
Save haydenmuhl/1176742 to your computer and use it in GitHub Desktop.
How do I use a generated text value as a key into a js object?
<html>
<head>
<title>asdf</title>
<script type="text/javascript" src="/giggity/js/jquery.js" ></script>
<script type="text/javascript">
$(document).ready(function () {
$("#branches option").click(
function() {
window.location.href = branchUrls[$(this).text()];
}
);
});
</script>
<script type="text/javascript">
var branchUrls = {
"fedora-temp": "/giggity/repo/gitolite/branch/fedora-temp",
"gh-pages": "/giggity/repo/gitolite/branch/gh-pages",
"master": "/giggity/repo/gitolite/branch/master",
"pu": "/giggity/repo/gitolite/branch/pu",
"pu-ssh-plus": "/giggity/repo/gitolite/branch/pu-ssh-plus",
"temp-br--data-dumper-problem-demo": "/giggity/repo/gitolite/branch/temp-br--data-dumper-problem-demo",
"vrs": "/giggity/repo/gitolite/branch/vrs"
}
</script>
</head>
<body>
<p>Branches</p>
<select id="branches">
<option>fedora-temp</option>
<option>gh-pages</option>
<option>master</option>
<option>pu</option>
<option>pu-ssh-plus</option>
<option>temp-br--data-dumper-problem-demo</option>
<option>vrs</option>
</select>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment