Lost Password?

Go Back   CodeCall Programming Forum > Web Development Forum > AJAX

AJAX Web based language that allows asynchronous loading of pages that does not interfere with normal page loading.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-05-2007, 07:40 AM
monalisa_smile monalisa_smile is offline
Newbie
 
Join Date: Oct 2007
Posts: 1
Rep Power: 0
monalisa_smile is on a distinguished road
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 :
PHP 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:
PHP 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>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #2 (permalink)  
Old 11-06-2007, 07:11 PM
fahlyn's Avatar   
fahlyn fahlyn is offline
Learning Programmer
 
Join Date: Nov 2007
Age: 24
Posts: 35
Rep Power: 3
fahlyn is on a distinguished road
Send a message via ICQ to fahlyn Send a message via AIM to fahlyn Send a message via MSN to fahlyn Send a message via Yahoo to fahlyn
Default

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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 11-07-2007, 03:11 PM
Lop's Avatar   
Lop Lop is offline
Speaks fluent binary
 
Join Date: May 2006
Posts: 1,135
Rep Power: 15
Lop is on a distinguished road
Default

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.
__________________
Lop
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 11-17-2007, 11:24 AM
fahlyn's Avatar   
fahlyn fahlyn is offline
Learning Programmer
 
Join Date: Nov 2007
Age: 24
Posts: 35
Rep Power: 3
fahlyn is on a distinguished road
Send a message via ICQ to fahlyn Send a message via AIM to fahlyn Send a message via MSN to fahlyn Send a message via Yahoo to fahlyn
Default

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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT -5. The time now is 11:18 PM.

Contest Stats

dargueta ........ 93.00000
John ........ 87.50000
Xav ........ 50.00000
MeTh0Dz ........ 20.00000
gaylo565 ........ 18.00000
Johnnyboy ........ 3.00000

Contest Rules

Ads