I`m having problem in getting an attribute from a xml object into JavaScript from classic asp. The following is my code:
if(len>0){
<%for xx=0 to SNodes.length-1%>//asp code
{
//Javascript code
var IXmlNode=xmlnewObj.createElement("I");
IXmlNode.setAttribute("a",document.getElementById('a'+xx).value);
IXmlNode.setAttribute("X","<%=SNodes.item(xx).getAttribute("PP")%>");
xmlnewObj.documentElement.appendChild(IXmlNode);
<% next %>//asp code
}
}
Here SNodes has xml like:
<tag><tag1 a="iii" PP="asdasdf"/><tag1 a="aaa" PP="asdasdf"></tag>
Only this line is troubling me:
IXmlNode.setAttribute("X","<%=SNodes.item(xx).getAttribute("PP")%>");
What is wrong with this line?
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:
It could work like this, but I still doubt that’s what you need:
You’re best option is probably to turn it into a function and pass your asp variables into it: