SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Guru Richi's Avatar
    Join Date
    Jul 2001
    Location
    Hu,Bp.
    Posts
    842
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Triple combo script .. How ..

    hi ..

    i need to code to do this ..

    i have 3 combo box (select tag), when user select from the 1st box item will see in the 2nd box the related items to the 1st box selected item, then when he select item from the 2nd box, will see the related items to the 2nd box .



    how could be with js ?!

  2. #2
    Currently Occupied; Till Sunda Andrew-J2000's Avatar
    Join Date
    Aug 2001
    Location
    London
    Posts
    2,475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you can pull this off of your database using remote scripting,

    http://www.ashleyit.com/rs/jsrs/select/php/select.php

    other than that if your didn't want to pull it dynamically you can see here

    http://members.aol.com/grassblad/html/selCascade1.html

  3. #3
    SitePoint Guru Richi's Avatar
    Join Date
    Jul 2001
    Location
    Hu,Bp.
    Posts
    842
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i write on my way

    PHP Code:
    Class Cars {
        
        
        Function 
    Car_Select($Form_Name){
            
            
    $q mysql_query("select * from car_zoon ");
            

            
    $car_menu =   "<select name=\"Zoon\" onchange=\"gettype(this)\" >\n\n";
            
    $car_menu .=   "<option value=\"AllZoon\" >All Zoon</option>\n\n";
            
            
            while(
    $r=mysql_fetch_array($q)){
                
    extract($r);
                
    $car_menu .=    "<option value=\"$zid\">&nbsp; $zoon </option>\n\n";
            }
            
    $car_menu .=   "</select>";
            
            
            
            
    ///////////////////////// part 2
            
            
        
            
    $car_menu .=    "<br><select name=\"Type\" onchange=\"getmodel(this)\">\n\n ";
            
    $car_menu .=   "<option value=\"AllType\"> كافة الأنواع </option>\n\n";
            
            
            
    $car_menu .=    "      <SCRIPT language=JavaScript>
                    function gettype(elem){
                    for (var i = document.
    $Form_Name.Type.options.length; i >= 0; i--){
                    document.
    $Form_Name.Type.options[i] = null;
                    }\n\n "
    ;
            
            
    $car_menu .=    "if (elem.options[elem.selectedIndex].value=='AllZoon'){ \n\n";
            
    $car_menu .=    "document.$Form_Name.Type.options[document.$Form_Name.Type.options.length] = new Option(' كافة المدن ','AllType');\n}\n";
            
            
    $q2 mysql_query("select *  from car_zoon");
            
            while(
    $r2=mysql_fetch_array($q2)){
                
                
    $car_menu .=   "if (elem.options[elem.selectedIndex].value=='$r2[zid]'){ \n";
                
    $q3 = @mysql_query("select *  from car_type where zid='$r2[zid]' ") ;
            
                
    $car_menu .=    "document.$Form_Name.Type.options[document.$Form_Name.Type.options.length] = new Option(' كافة المدن ','AllType');\n";
                while(
    $r3=@mysql_fetch_array($q3)){
                    
                
    $car_menu .=    "document.$Form_Name.Type.options[document.$Form_Name.Type.options.length] = new Option(' $r3[type] ','$r3[car_id]');\n";
                }
            
    $car_menu .=    "}\n";
            }
            
            
            
    $car_menu .=   "}</script>\n\n";
            
    $car_menu .=   "</select>";

            
    //////// Part 3
            
            
            
            
    $car_menu .=    "<br><select name=\"Model\">\n\n ";
            
    $car_menu .=   "<option value=\"AllModel\"> كافة المدن </option>\n\n";
            
            
            
    $car_menu .=    "      <SCRIPT language=JavaScript>
                    function getmodel(item){
                        
                    for (var i = document.
    $Form_Name.Model.options.length; i >= 0; i--){
                    document.
    $Form_Name.Model.options[i] = null;
                    }\n\n"
    ;
            
            
    $car_menu .=    "if (item.options[item.selectedIndex].value=='AllType' ){  \n\n";
            
    $car_menu .=    "document.$Form_Name.Model.options[document.$Form_Name.Model.options.length] = new Option(' كافة المدن ','AllModel');\n}\n";
            
            
    $q2 mysql_query("select *  from car_type");
            
            while(
    $r2=mysql_fetch_array($q2)){
                
                
    $car_menu .=   "if (item.options[item.selectedIndex].value=='$r2[car_id]'){  \n";
                
    $car_menu .=    "document.$Form_Name.Model.options[document.$Form_Name.Model.options.length] = new Option(' كافة المدن ','AllModel');\n";
                
    $q3 mysql_query("select *  from car_model where mid='$r2[car_id]' ") ;
                while(
    $r3=mysql_fetch_array($q3)){
                    
                
    $car_menu .=    "document.$Form_Name.Model.options[document.$Form_Name.Model.options.length] = new Option(' $r3[model] ','$r3[mid]');\n";
                }
            
    $car_menu .=    "}\n";
            }
            
            
            
    $car_menu .=   "}</script>\n\n";
            
    $car_menu .=   "</select>";
            
            return 
    $car_menu;
        } 
    // func End...
        
        
    }// class End. 


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
  •