javascript pass XML document object as argument
I am reading an XML document to dynamically populate select boxes. The first select box is populated with all the activity names which i have done already in jsp.
DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
Document doc = docBuilder.parse("C:\\Projects\\RegressionTester\\src\\main\\resources\\TestActivitiesXML.xml");
NodeList activityNodes = doc.getElementsByTagName("activity");
Upon selecting an activity the next select box should be populated with the activity's functions. I am trying to acc开发者_高级运维omplish through a javascript method using the onchange eventhandler. But I have trouble passing the doc object as an argument. Any help would be appreciated.
onchange="return testMethodChange(this,<%=doc%>)"
If you pass like this testMethodChange(this,<%=doc%>). It will not work because testMethodChange will only get some text.
Instead read and parse TestActivitiesXML.xml in javascript function itself.
After parsing the XML populate it in drop down according to your requirement.
精彩评论