If myFunc(variable) is executed before the textarea is rendered to the page, you will get the null exception error.
<html>
<head>
<title>index</title>
<script type="text/javascript">
function myFunc(variable) {
var s = document.getElementById(variable);
s.value = "new value";
}
myFunc("id1");
</script>
</head>
<body>
<textarea id="id1"></textarea>
</body>
</html>
<!-- Error message: Cannot set property 'value' of null -->
So, make sure your textarea does exist on the page, and then call myFunc. You can use the window.onload or $(document).ready function.