问题描述
我正在阅读XML文档,以动态填充选择框.在第一个选择框中填充所有我在jsp中已经完成的活动名称.
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");
选择活动后,应使用活动功能填充下一个选择框.我试图通过使用onchange eventhandler的javascript方法来完成.但是我在传递doc对象作为参数时遇到了麻烦.任何帮助将不胜感激.
Upon selecting an activity the next select box should be populated with the activity's functions. I am trying to accomplish 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%>)"
推荐答案
-
如果您这样通过 testMethodChange(this,<%= doc%>).这将不起作用,因为 testMethodChange 只会得到一些文本.
If you pass like this testMethodChange(this,<%=doc%>). It will not work because testMethodChange will only get some text.
而是在javascript函数本身中读取并解析 TestActivitiesXML.xml .
Instead read and parse TestActivitiesXML.xml in javascript function itself.
解析XML之后,根据您的要求将其填充到下拉列表中.
After parsing the XML populate it in drop down according to your requirement.
这篇关于javascript将XML文档对象作为参数传递的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!