If you're looking for a quick solution, one option is to utilize the document.write() method directly within your code. Consider using a preexisting function designed to retrieve cookies, like this one:
// adapted from http://www.elated.com/articles/javascript-and-cookies/
function get_cookie ( cookie_name ){
var results = document.cookie.match ( '(^|;) ?' + cookie_name + '=([^;]*)(;|$)' );
if ( results )
return ( unescape ( results[2] ) );
else
return null;
}
Then, in your HTML file, incorporate something along these lines:
<div id="container">
<script>
if (get_cookie("cookiename") == null){
document.write("[cookie exists message]")
} else {
document.write('<input type="button" id='approve' value="approve" onclick="a()"/><input type="button" id='reject' value="reject" onclick="r()"/>')
}
</script>
</div>
To delay rendering until after the page has loaded, you can follow this approach:
function showit(){
var myhtml;
if (get_cookie("cookiename") == null){
myhtml = "some message";
} else {
myhtml = '<input type="button" id='approve' value="approve" onclick="a()"/><input type="button" id='reject' value="reject" onclick="r()"/>'
}
document.getElementById("container").innerHTML = myhtml;
}