Results 1 to 3 of 3

Thread: dropdown list and parse xml!

  1. #1
    Join Date
    Mar 2012
    Posts
    3

    dropdown list and parse xml!

    Hello,
    I have two dropdown menu that takes data from an xml file (parse method).
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <script TYPE="text/javascript" SRC="../java/jquery_v1.7.1.js"></script>
    <meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    <script TYPE="text/javascript">
    $(document).ready(function() {
    var course_data;  
    var course_data2;    
     $.get('exercise.xml', function(data) {
        course_data = data;
        course_data2 = data;        
          var that = $('#courses'); 
            $('course', course_data).each(function() { 
              $('<option>').text($(this).attr('title')).appendTo(that);
            });
    
          var that = $('#chapter');     
            $('chapter', course_data2).each(function() { 
              $('<option>').text($(this).attr('title')).appendTo(that);
            });
    
     }, 'xml'); 
    
    $('#courses').change(function() { 
        var val = $(this).val(); 
        var that = $('#times').empty(); 
        $('course', course_data).filter(function() { 
            return val == $(this).attr('title'); 
        })
        .find("lesson").each(function() { 
    
            $("#lesson").val($(this).text()); 
    
        });
    });
    });
    </script>
    
    </head>
    <body>
    <form id="form_1" name="form_1" METHOD="post" ACTION="">
    <input SIZE="90" TYPE="text" id="lesson"/>
    </form>         
    
    <div>
    <form name="form1" >
    <p>chapters
    <select STYLE="width:150px" SIZE="1" id="chapter"> 
    <option selected="selected">choose a chapter...</option>
    </select></p> 
    <p>exercises
    <select STYLE="width:150px" id='courses'>
    <option selected="selected">choose an exercise...</option>
    </select>
    </form>
    </div> 
    </body>
    </html>
    exercise.xml:
    Code:
    <courses>
    <chapter title="chapter 1">
        <course title="exercise 1">
        <lesson>aaaa aaaa aaaa</lesson>
        </course>
        <course title="exercise 2">
        <lesson>bbbb bbbb bbbb</lesson>
        </course>
        <course title="exercise 3">
        <lesson>cccc cccc cccc</lesson>
        </course>
    </chapter>
    <chapter title="chapter 2">
        <course title="exercise 1">
        <lesson>dddd dddd dddd</lesson>
        </course>
        <course title="exercise 2">
        <lesson>eeee eeee eeee</lesson>
        </course>
        <course title="exercise 3">
        <lesson>ffff ffff ffff</lesson>
        </course>
        <course title="exercise 4">
        <lesson>gggg gggg gggg</lesson>
       </course>
    </chapter>
    </courses>
    I want to choose "chapter 1" from the first dropdown, and show me only the first three choices in the second dropdown, "chapter 2" the next four choices, etc... Τhe content of field "lesson" are presented in the input field

    Code:
    **dropdown1**     **dropdown2**           **input field**
      chapter 1   -->   exercise 1             aaaa aaaa aaaa
                        exercise 2             bbbb bbbb bbbb
                        exercise 3             cccc cccc cccc
    
      chapter 2   -->   exercise 1             dddd dddd dddd
                        exercise 2             eeee eeee eeee
                        exercise 3             ffff ffff ffff
                        exercise 4             gggg gggg gggg
    I make some changes but it doesn't work correct. Show me all the exercises together, but i want to separate by chapters. Any suggestion?
    Thanks in advance

  2. #2
    Join Date
    Jan 2006
    Posts
    605

    Re: dropdown list and parse xml!

    You can try to make invoke a shortlived process [which populates your dropdown values, example: Query for Multiple Rows as XML service] when the user start a process from workspace and prepopulate a dropdown list using that xml file.

  3. #3
    Join Date
    Mar 2012
    Posts
    3

    Re: dropdown list and parse xml!

    ok, I found it.

Similar Threads

  1. Replies: 3
    Last Post: 26-03-2012, 07:01 PM
  2. DropDown list in JSP
    By Isabella in forum Software Development
    Replies: 4
    Last Post: 22-07-2010, 12:28 PM
  3. PHP Parse error: parse error unexpected $ in main.php on line 12
    By ΘN-TH3-ЯΘCKZ in forum Software Development
    Replies: 3
    Last Post: 20-08-2009, 06:07 PM
  4. How to create dropdown list under tab in HTML
    By Mentos in forum Windows Software
    Replies: 3
    Last Post: 30-07-2009, 11:49 AM
  5. IE8 Dropdown list can not open
    By advsnhal in forum Windows Software
    Replies: 5
    Last Post: 09-04-2009, 01:56 PM

Tags for this Thread

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
  •  
Page generated in 1,710,843,122.85133 seconds with 16 queries