Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Feb 2006
    Posts
    26
    Thanks
    0
    Thanked 0 Times in 0 Posts

    dropdown list from xml

    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.

    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

  • #2
    New Coder
    Join Date
    Apr 2007
    Posts
    24
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thumbs up solution for ur problem

    <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>


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •