<?php
echo "<script type='text/JavaScript'>";
echo "document.getElementById('testboxid').value='hehe';";
echo "</script>";
?>
I call this function with AJAX. I'll be changing hehe to date() later, to get a value that changes all the time. But for that to work this is the first step.
<input name="test_button" type="button" onClick="ajaxRequest('test.php', 'testboxid', 'POST');" value="Test" />
Firebug says this was the response:
<script type='text/JavaScript'>document.getElementById('testboxid').value='hehe';</script>
However, testbox doesn't update with hehe. But if I just write echo "hehe" and change the
ajaxRequest('test.php', 'testboxid', 'POST');
to
ajaxRequest('test.php', 'divid', 'POST');
the text at divid updates.