[eluser]markanderson993[/eluser]
Hello there CodeIgniter experts, I am trying to get my simple piece of javascript/html code that works on a normal page like <html><head></head><body>...code here</body></html> but does not work when I copy it into my view.
This is the code I am working with
Code:
[removed]
window.onload = initAll;
function initAll() {
document.getElementsByTagName("form")[0].onsubmit = addNode;
alert("hi");
}
function addNode() {
alert("form submitted");
var inText = document.getElementById("textArea").value;
var newText = document.createTextNode(inText);
var newGraf = document.createElement("p");
newGraf.appendChild(newText);
var docBody = document.getElementsByTagName("body")[0];
docBody.appendChild(newGraf);
return false;
}
[removed]
<div style="margin:5px;border-bottom:1px solid #000;padding:5px;font-size:14px;">Ajax Interface</div>
<form action="#">
<table style="width:100%" cellspacing="5px">
<tr>
<td>
<textarea id="textArea" rows="5" cols="30"></textarea>
<div style="clear:both;height:5px;"></div>
<input type="submit" value="submit" />
</td>
<td style="vertical-align:top">Add some text to the page</td>
</tr>
</table>
</form>
Does anyone know why it works on a normal page and not in CodeIgniter?
Any help would be greatly appreciated!