<script>
function myFunction(x) {
alertify.prompt('Prompt Title', x, '1'
, function (evt, value)
{
}
, function () {
alertify.error('Cancel') });
}
</script>
//string should be in "", so you need to escape them!
document.write("<button id='button' type='button' onclick="getHistoryByYear('+ year + "," + '"' + string + '"' +')">click</button>")