ThorWiumGiversen
Programmer
Hi i am messing around with some code from and i´ve run in to a problem. I am trying to dynamically create <textareas> and for some reason i cannot remove the <switch>. Here is what i have in my script
<script>
var counterTextArea = 1;
function addAllInputs(divName, inputType){
var newdiv = document.createElement('div');
switch(inputType) {
case 'textarea':
newdiv.innerHTML = "Entry " + (counterTextArea) + " <br><textarea name='myTextAreas[]'>type here...</textarea>";
counterTextArea++;
}
document.getElementById(divName).appendChild(newdiv);
}
</script>
and here is what i have in html
<form name="myForm" method="POST">
<div id="dynamicInputs"></div>
<input type="button" value="Add new Chapter" onClick="addAllInputs('dynamicInputs', 'textarea');">
</form>
I hope that someone can help me.
Regards Thor Giversen
<script>
var counterTextArea = 1;
function addAllInputs(divName, inputType){
var newdiv = document.createElement('div');
switch(inputType) {
case 'textarea':
newdiv.innerHTML = "Entry " + (counterTextArea) + " <br><textarea name='myTextAreas[]'>type here...</textarea>";
counterTextArea++;
}
document.getElementById(divName).appendChild(newdiv);
}
</script>
and here is what i have in html
<form name="myForm" method="POST">
<div id="dynamicInputs"></div>
<input type="button" value="Add new Chapter" onClick="addAllInputs('dynamicInputs', 'textarea');">
</form>
I hope that someone can help me.
Regards Thor Giversen