I have been trying to change the height of textarea when the user hits enter so they do not have to scroll. i could mange it on IE and Chrome however i could not make it work on Firefox. Please have a look at my code. i am really new to this. it seems like it does not recognize event and i could not figure out a way around. Here is my code:
<form id="blog-comment-form" method="post" action="index.php">
<textarea id="comment" name="b_com" onkeyup="showmsg()" placeholder="ADD YOUR COMMENT HERE"></textarea>
<input type="submit" name="submit" value="POST COMMENT"/>
</form>
i am calling the function from an external file. And my javascript code:
function showmsg() {
if(!event){
event= window.event;}
if (event.keyCode==13) {
var a = document.getElementById("comment");
var b = document.getElementById("comment").style.scrollHeight;
a.style.height = ((a.scrollHeight)+6) + "px";
}else {
var a = document.getElementById("comment");
var b = document.getElementById("testthis").style.height;
a.style.height = ((a.scrollHeight)+6) + "px";
}
}
Thank You
Write this:
function showmsg(event) {
in place of:
function showmsg() {
AND
write this (in HTML markup):
onkeyup="showmsg(event)"
in place of:
onkeyup="showmsg()"