Entry
How can I add textareas to a page?
How can I add textareas to a page?
Aug 25th, 2000 08:27
Martin Honnen,
NN6 and IE4+ can add textareas dynamically to a FORM element. NN4 can
only add new Layer elements which need to contain complete FORMs each.
Here is an example showing the addition of the textareas/textarea
layers:
<HTML>
<HEAD>
<SCRIPT>
if (document.layers)
window.setResizable(false);
var c = 0;
function addTextArea (form) {
if (document.all) {
var html = '<BR><TEXTAREA NAME="aTextArea' + c++ + '" ROWS="5"
COLS="40"><\/TEXTAREA>';
form.insertAdjacentHTML('beforeEnd', html)
}
else if (document.getElementById) {
var textarea = document.createElement('TEXTAREA');
textarea.name = 'aTextArea' + c++;
textarea.rows = 5;
textarea.cols = 40;
form.appendChild(document.createElement('BR'));
form.appendChild(textarea);
}
else if (document.layers) {
var l = new Layer (window.innerWidth);
var html = '';
html += '<HTML><BODY><FORM NAME="formName">';
html += '<TEXTAREA NAME="aTextArea" ROWS="5"
COLS="40"><\/TEXTAREA>';
html += '<\/FORM><\/BODY><\/HTML>';
l.document.open();
l.document.write(html);
l.document.close();
l.top = document.height;
document.height += l.document.height;
l.visibility = 'show';
}
}
</SCRIPT>
</HEAD>
<BODY>
<FORM NAME="formName">
<INPUT TYPE="button" VALUE="add textarea"
ONCLICK="addTextArea(this.form)"
>
</FORM>
</BODY>
</HTML>