I am trying to apply javascript twice to a simple html textarea. I have onfocus and autogrow (which is actually jquery). It seems i can only get one or the other to work but never both at once.
My script has an:
<?php
include 'header.php';
?>
This seems to be the problem. In both the header.php and the index.php (where the header is included) I have loaded jquery.js. when I remove this file from the header, autogrow works but not my onfocus event (which clears the default text). Is there a way to include another file without the two effecting each other. I cant provide the code because it too long.
This is my onfocus code:
<script type='text/javascript'>
function addEvents(id) {
var field = document.getElementById(id);
field.onfocus = function () {
if (this.value == "Answer this problem...") {
this.value = "";
}
};
field.onblur = function () {
if (this.value == "") {
this.value = "Answer this problem...";
}
};
} addEvents("answerbox");