SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Addict
    Join Date
    Jan 2006
    Posts
    246
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    accessing xmlattributes

    this probably has a very easy sollution, but i've been looking at it all day, and i can't seem to find it

    what i'm trying to do is read the value of the "value" attribute in the following xml string:
    Code:
    <meeting>
      <text>success</text>
      <options>
        <option value="none">Select Meeting</option>
        <option value="1">Meeting (08.03.2007)</option>
        <option value="2">Meeting (09.03.2007)</option>
      </options>
    </meeting>
    i need it to repopulate a dropdown list (via ajax). To get the textNode inside the option tag is no problem, i've figured that out. But i'm having troubles with the attributes. here's the code that i'm currently using:

    Code:
    function updateMeetingList(opts){
      // opts is an XML Object that contains all nodes with the <options> tag in it
      var dropdown = document.getElementById('selected_meeting');
      for(var i=0; i<opts.length; i++){
        // text works fine
        var text = opts[i].firstChild.firstChild.nodeValue;
        // value doesn't work
        var value = toString(opts[i].firstChild.getAttribute("value"));
        dropdown.options[i] = new Option(text, value);
      }
    }

    thanks for ur time

  2. #2
    SitePoint Addict Mirek Komárek's Avatar
    Join Date
    Dec 2006
    Location
    Prague
    Posts
    210
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    value is reserved word

  3. #3
    SitePoint Guru SSJ's Avatar
    Join Date
    Jan 2007
    Posts
    828
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Mirek Komárek View Post
    value is reserved word
    Agree. You can't use value word.


Bookmarks

Posting Permissions

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