I am trying to change the id of a div tag by a new id coming from a queryString. I have a page that has a few links and I'm passing a unique id to another page to create a unique chart. I want to replace the div name 'replacement' with the new id from the querystring.
Here's what I have so far but it's not working. Any suggestions? Thx!
<script type="text/javascript">
var newID = getUrlString()["id"];
$(document).ready(function() {
alert(newID);
$("div.replacement").attr('id', newID);
buildChart(newID);
});
function getUrlString()
{
var vars = [], 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('=');
vars.push(hash[0]);
vars[hash[0]] = hash[1];
}
return vars;
}
</script>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<script type="text/javascript">
google.load('visualization', '1', {packages: ['corechart']});
</script>
</head>
<body>
<div id="replacement" style="width: 900px; height: 500px;"></div>
</body>
</html>