Closed Thread
Results 1 to 4 of 4

Thread: problem linking tripple combo boxes

  1. #1
    Join Date
    Oct 2007
    Posts
    1
    Rep Power
    0

    Exclamation problem linking tripple combo boxes

    I've a problem with linking tripple combo boxes I don't know what's going on but I've in console that there is a problem with line containing the onreadystatechange property of requestobj this the code for ajax :
    Code:
    <script language="javascript">
                var options;
                var requestobj = false;
                
                if(window.XMLHttpRequest) {
                    
                    requestobj = new XMLHttpRequest();
                    requestobj.overrideMimeType("text/xml");
                }
                else if(window.ActiveXObject) {
                    
                    requestobj = new ActiveXObject("Microsoft.XMLHTTP");
                }
                function getoptions(datasource, src, vlu, optionlist) {                            
                    if(vlu!=""){
                        var datasrc = "modules/mod_goods/"+datasource+"?cat="+src+"&comp="+vlu;
                        } else{
                            //alert("src: "+datasource+" cat: "+src);
                            var datasrc = "modules/mod_goods/"+datasource+"?cat="+src;
                        }
                        if(requestobj) {
                        
                            requestobj.open("GET", datasrc, true);
                            requestobj.onreadystatechange = function() {
                            if (requestobj.readyState == 4 && requestobj.status == 200) {
                                var doc  =  requestobj.responseXML;
                                options = doc.getElementsByTagName("option");
                                listoptions(optionlist);
                        }
                        requestobj.send(null);
                    }
                }
                }
                 function listoptions (optionlist)
          {
            var i;
            var selectControl = document.getElementById(optionlist);
            for (i = 0; i < options.length; i++ )
            {    
                
                val=options[i].getAttribute("value");
                selectControl.options[i] = new Option(options[i].firstChild.data);
            }
        }
        
            </script>

    <div id="nifty">
    <b class="rtop">
      <b class="r1"></b> <b class="r2"></b> <b class="r3"></b> <b class="r4"></b>
    </b>
    <center>
    <div id="container">
    <form action="<?php  $_SERVER['PHP_SELF'?>" method="POST">

         <fieldset>
         <p class="parag">Search:</p>
            <table>        
             <tr>
                <td class="attribute-value">Category: </td>
                <td>
                    <?php
                        $sel 
    export_categoryDalc::getAll();
                    
    ?>
                    <select name="cat" id="cat" onChange="getoptions('comp.php',this.value, '', 'comp')">
                        <option value="">All</option>
                        <?php
                            
                        
    foreach($sel as $cat)
                            {
                                echo
    "<option value='".$cat->id."'>".$cat->category_name."</option>";
                            }    
                        
    ?>
                </select>
                </td>
            </tr>
             <tr>
                <td class="attribute-value">Company:</td>
                <td>
                    <select name="comp" id="comp" onChange="getoptions('good.php', document.getElementById['cat'].value, this.value, 'good')">
                        <option value="">All</option>
                    </select>
                </td>
            </tr>        
            <tr>
                <td class="attribute-value">Good: </td>
                <td>
                    <select name="good" id="good">
                        <option value="">All</option>        
                    </select>
                </td>
            </tr>
            <tr>    
                <td colspan="2" align="right">
                <input type="submit" name="search_goods" value="search" class="search-button" style="width:auto; "> 
                <input type="hidden" name="page" value="goods"  />
                <input type="hidden" name="task" value="search"  />
                </td>
            </tr>
         </table>
         </fieldset>

       </form>
       </div>
       </center>
       <b class="rbottom">
      <b class="r4"></b> <b class="r3"></b> <b class="r2"></b> <b class="r1"></b>
    </b>
       </div>
    and this ius for xml:
    Code:
    <?php
        
        header
    ("Content-type: text/xml");
             echo 
    '<?xml version="1.0"?>';
            
    $cat_id $_GET['cat'];    
        include(
    "../../admin_panel/db.php");

        include(
    "../../configuration.php");

        include(
    "../../admin_panel/components/zad/dalcs/dalc.php");
            include(
    "../../admin_panel/components/zad/dalcs/class.goods.php");
                
            
    $comp export_goodsDalc::getCompany($cat_id);
    ?>
    <options>
        <option value="">All</option>
    <?php
                
    foreach ($comp as $value)
                {
                    echo 
    '<option value="'.$value->company_id.'">';
                    echo 
    $value->company_name;
                    echo 
    '</option>';
                }
    ?>
    </options>

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Posts
    Many

     
  3. #2
    fahlyn's Avatar
    fahlyn is offline Learning Programmer
    Join Date
    Nov 2007
    Posts
    35
    Rep Power
    0
    you should very seriously consider using prototype.js instead of writing your own ajax javascript. Prototype provides a very nice wrapper for ajax...and it prevents you from having to re-invent the wheel.

    Switching to prototype may fix your problem.
    Visit My Google Group Here: Web Development Innovation

  4. #3
    Lop's Avatar
    Lop
    Lop is offline Speaks fluent binary
    Join Date
    May 2006
    Posts
    1,178
    Rep Power
    30
    Quote Originally Posted by fahlyn View Post
    you should very seriously consider using prototype.js instead of writing your own ajax javascript. Prototype provides a very nice wrapper for ajax...and it prevents you from having to re-invent the wheel.

    Switching to prototype may fix your problem.
    Wow, that is a nice little class! I'm going to use that in my next AJAX client (given that I make one). JSON looks pretty neat as well. Never heard of it until now.

  5. #4
    fahlyn's Avatar
    fahlyn is offline Learning Programmer
    Join Date
    Nov 2007
    Posts
    35
    Rep Power
    0
    Personally, I very much prefer JSON to XML when using Ajax. it completely removes the need to parse XML in JavaScript. Glad you like it.
    Visit My Google Group Here: Web Development Innovation

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Allegro linking problem
    By vaironl in forum C and C++
    Replies: 1
    Last Post: 09-01-2011, 12:03 AM
  2. Linking problem
    By MDM in forum General Programming
    Replies: 0
    Last Post: 11-06-2010, 04:16 PM
  3. Combo boxes and saving
    By Halfie44 in forum C# Programming
    Replies: 20
    Last Post: 06-22-2010, 06:17 PM
  4. JTable Combo Boxes in Rows and Columns
    By chili5 in forum Java Help
    Replies: 0
    Last Post: 06-28-2009, 01:57 PM
  5. linking SQL database with C# problem
    By Siten0308 in forum C# Programming
    Replies: 14
    Last Post: 07-02-2008, 03:50 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