...

View Full Version : dropdown list from xml



rosehabib
04-21-2007, 06:39 AM
hello guys,
i have problem with xml.
i want the value and text in drop down list retrieve from xml.

for example, i have 2 dropdown list called:
1. drpSelect
2. drpView

what i want to do is:

this is xml code.


<?xml version="1.0" encoding="utf-8" ?>

<criterias>

<drpSelect>
<criteriaSelect>
<textSelect>Search All</textSelect>
<valueSelect>All</valueSelect>
</criteriaSelect>

<criteriaSelect>
<textSelect>- Sender</textSelect>
<valueSelect>0</valueSelect>
</criteriaSelect>

<criteriaSelect>
<textSelect>- Receiver</textSelect>
<valueSelect>1</valueSelect>
</criteriaSelect>

</drpSelect>

<drpView>
<criteria>
<text>View All</text>
<value>viewAll</value>
</criteria>

<criteria>
<text>- Incoming</text>
<value>viewIn</value>
</criteria>

<criteria>
<text>- Outgoing</text>
<value>viewOut</value>
</criteria>

</drpView>

</criterias >

then, i want the first dropdown retrieve the value from drpSelect tag (<drpSelect>) and the second dropdown retrieve value from drpView tag (<drpView>)...

anyone have suggestion, can reply to me...
tq

venkatmallu.net
04-27-2007, 02:19 PM
<HTML>
<HEAD>
<META NAME="GENERATOR" >
<TITLE></TITLE>
<script language="JavaScript">


function func()
{
var xmlObj = new ActiveXObject("Microsoft.XMLDOM");
xmlObj.async='false';
xmlObj.load("dd.xml");
var val=xmlObj.documentElement;
for(i=0;i<val.childNodes.length;i++)
{
switch(i)
{
case 0:
for (j=0;j<3;j++)
{

var op=document.createElement("Option");
op.text=xmlObj.documentElement.childNodes.item(i).childNodes.item(j).childNodes.item(0).text;
op.value=xmlObj.documentElement.childNodes.item(i).childNodes.item(j).childNodes.item(0).text;
fmnm.drpSelect.add(op);
}break;
case 1:
for (j=0;j<3;j++)
{
var op1=document.createElement("Option");

op1.text=xmlObj.documentElement.childNodes.item(i).childNodes.item(j).childNodes.item(0).text;
op1.value=xmlObj.documentElement.childNodes.item(i).childNodes.item(j).childNodes.item(0).text;
fmnm.drpView.add(op1);
}break;
}
//alert(xmlObj.documentElement.childNodes.item(i).childNodes.item(0).childNodes.item(0).text);
}
}
</script>
</HEAD>
<BODY onload="func();">
<form name="fmnm">
<P>Select
<SELECT name=drpSelect>

</SELECT>
</p><br><br>
<p>View
<SELECT name=drpView>
</SELECT>
</p><br><br>
</form>
</BODY>
</HTML>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum