Hi everyone I have a strange Behaviour issue with Sharepoint.
I'm testing some javascript in the content editor web part and ran accross this issue. When Creating DOM Elements dynamically in a normal HTML Page as shown below, I am able to retrieve the values from the created Element.
When I however try this in a Sharepoint Content Editor web part, I get the JS error back from the SharePoint Page stating : "0.value1" is null or not an object.
Any idea why this is happening?
<head>
<script type="text/javascript">
function WriteElements()
{
var input = document.createElement("input");
input.setAttribute("type", "hidden");
input.setAttribute("name", "BLABLA");
input.setAttribute("value1", "ASDFASDFZXCV");
document.getElementById('theUL').appendChild(input);
var i = document.getElementsByName("BLABLA");
alert(i[0].value1);
return;
}
</script>
</head>
<body>
<ul id="theUL"></ul>
<p><input id="Button1" type="button" value="button" onclick="WriteElements();"/></p>
</body>