I am using the below code. which gets the posts from my blog and displays the most recent in a div. The other div is a select drop down that when i change does update the values I require from the json file (i am using alert to test this) however it wont update the blog1 div with the new content from the corrosponding blog post. What am I missing?
<script>
function getBlogidval(selectObject) {
var value = selectObject.value;
var upblog = document.getElementById("blog1");
alert(value);
upblog.innerHTML = "<h2>" + data.items[value].title + "</h2><br>"
}
function handleResponse(response) {
document.getElementById("blog0").innerHTML = "<select id='Blogidval' onchange='getBlogidval(this)' width='100%' align='center'><option value='0'><h2>" + response.items[0].title + "</h2></option>"
+ "<option value='1'><h2>" + response.items[1].title + "</h2></option>"
+ "<option value='2'><h2>" + response.items[2].title + "</h2></option>"
+ "<option value='3'><h2>" + response.items[3].title + "</h2></option><select>"
;
document.getElementById("blog1").innerHTML = "<h2>" + response.items[0].title + "</h2><br>" + "<p>" + response.items[0].content + "</p>" ;
}
</script>
handleRepsonse calls the json from from the google API. same as below but with my api key and blog ID.
Any help would be greatly appreciated. 🙂
Daniel Boardman is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.