What kind of javascript are you trying to output in the first place? As it stand now you'll get something like this which would never work:
if (len > 0) {
{
var IXmlNode = xmlnewObj.createElement("I");
IXmlNode.setAttribute("a", document.getElementById('a' + xx).value);
IXmlNode.setAttribute("X", "PP");
xmlnewObj.documentElement.appendChild(IXmlNode);
}
{
var IXmlNode = xmlnewObj.createElement("I");
IXmlNode.setAttribute("a", document.getElementById('a' + xx).value);
IXmlNode.setAttribute("X", "PP2");
xmlnewObj.documentElement.appendChild(IXmlNode);
}
}
It could work like this, but I still doubt that's what you need:
if (len > 0) {
(function() {
var IXmlNode = xmlnewObj.createElement("I");
IXmlNode.setAttribute("a", document.getElementById('a' + xx).value);
IXmlNode.setAttribute("X", "asdasdf");
xmlnewObj.documentElement.appendChild(IXmlNode);
})();
(function() {
var IXmlNode = xmlnewObj.createElement("I");
IXmlNode.setAttribute("a", document.getElementById('a' + xx).value);
IXmlNode.setAttribute("X","asdasdf");
xmlnewObj.documentElement.appendChild(IXmlNode);
})();
}
You're best option is probably to turn it into a function and pass your asp variables into it:
if(len>0){
<%for xx=0 to SNodes.length-1%>//asp code
{
xmlAppender(<%=xx%>, <%=SNodes.item(xx).getAttribute("PP")%>);
}
<% next %>
}
var xmlAppender = function(i, childData) {
var IXmlNode = xmlnewObj.createElement("I");
IXmlNode.setAttribute("a", document.getElementById('a' + i).value);
IXmlNode.setAttribute("X", childData);
xmlnewObj.documentElement.appendChild(IXmlNode);
};