<script>
function readxml(){
var xmldoc=dbck.XMLDocument;
var node=xmldoc.selectSingleNode('//VehicleList');
var subnodes=node.childNodes;
var objSel=document.all.TestSelect;
for(var i=0;i<subnodes.length;i++){
var subnode=subnodes(i);
var o=document.createElement("option");
o.text=subnode.childNodes(1).text;
o.value=subnode.childNodes(0).text;
objSel.add(o);
}
}
</script>
<body onload=readxml()>
<xml ID="dbck">
<VehicleList>
<Vehicle>
<vID>1</vID>
<DriverID>A</DriverID>
</Vehicle>
<Vehicle>
<vID>2</vID>
<DriverID>B</DriverID>
</Vehicle>
<Vehicle>
<vID>3</vID>
<DriverID>C</DriverID>
</Vehicle>
</VehicleList>
</xml>
<table width="100%" height="135" border="0">
<tr>
<td width="14%"> </td>
<td width="86%">
<select name="TestSelect">
</select>
</td>
</tr>
</table>
</body>
function readxml(){
var xmldoc=dbck.XMLDocument;
var node=xmldoc.selectSingleNode('//VehicleList');
var subnodes=node.childNodes;
var objSel=document.all.TestSelect;
for(var i=0;i<subnodes.length;i++){
var subnode=subnodes(i);
var o=document.createElement("option");
o.text=subnode.childNodes(1).text;
o.value=subnode.childNodes(0).text;
objSel.add(o);
}
}
</script>
<body onload=readxml()>
<xml ID="dbck">
<VehicleList>
<Vehicle>
<vID>1</vID>
<DriverID>A</DriverID>
</Vehicle>
<Vehicle>
<vID>2</vID>
<DriverID>B</DriverID>
</Vehicle>
<Vehicle>
<vID>3</vID>
<DriverID>C</DriverID>
</Vehicle>
</VehicleList>
</xml>
<table width="100%" height="135" border="0">
<tr>
<td width="14%"> </td>
<td width="86%">
<select name="TestSelect">
</select>
</td>
</tr>
</table>
</body>
要想实现数据添加,用DOM例如:
<body>
<xml ID="dbck">
<VehicleList>
<Vehicle>
<vID>1</vID>
<DriverID>A</DriverID>
</Vehicle>
<Vehicle>
<vID>2</vID>
<DriverID>B</DriverID>
</Vehicle>
<Vehicle>
<vID>3</vID>
<DriverID>C</DriverID>
</Vehicle>
</VehicleList>
</xml>
<table width="100%" height="135" border="0">
<tr>
<td width="14%"> </td>
<td width="86%">
<select name="TestSelect" id="TestSelect" DATASRC="#dbck" DATAFLD="DriverID">
<option value="C">C</option>
<option value="A">A</option>
<option value="B">B</option>
</select></td>
</tr>
</table>
</body>
现在结帖。