I have a "messages" page where it is possible to comment on every message. I'm doing a facebook-like textarea where when you focus it shows the submit button and when you onblur it hides it again. So far i've tried some different things:
<script type="text/javascript">
function focusTextarea(id) {
var form = document.forms[id];
//Create an input type dynamically.
var element = document.createElement("input");
//Assign different attributes to the element.
element.setAttribute("type", "submit");0
element.setAttribute("value", "Post comment");
element.setAttribute("name", "createComment");
element.setAttribute("class", "okButton");
element.setAttribute("id", "test");
var foo = document.getElementById("commentButton");
//Append the element in page (in span).
form.appendChild(element);
}
function unFocusTextarea(id) {
var test = document.getElementById(id);
var foo = document.getElementById("commentButton");
var foo2 = document.getElementById("test");
foo.removeChild(foo2);
}
</script>
The parameter id is the form name and id. In first function i want to find the form and insert a submit button. The second function i want to again find the form and remove the button.
Thanks in advance