Location: PHPKode > projects > MembersGear > membersgear/includes/fill_states.php
<?php
require_once("../config/config.php");   
require_once INCLUDE_DIR."/users_class.php";

if(isset($_POST['country']))
 {    
    
        $ajexval=$_POST['ajexvalidation'];
        $a = $_POST['country'];

        $lsValues = array();
        $users = new users_class();
        sleep(1);


         if($ajexval=="usersignup")   
         {
            $result="usersignup[|||]"; 
            $result.= "<select id='state' name='state' class='selectcss' style='width:208px'>";
         }
        else
        {
             $result="adminusersignup[|||]";
             $result .= "<select id='state' name='state' class='selectcss'>";      
         
         }
            $result.="<option value='0'>select..</option>";
            $lTypes=null;
            
            //If Select is selected then
            if($a==0)
                $a=-1;
               
             $query= "SELECT id,name FROM ".TABLE_PREFIX."location where parentid=$a  and status=1 order by name asc";
               
            $Stateresult = $users->View($query);
            $i = 0;
            $length=count($Stateresult);
            if($length==1 && $Stateresult[0]['id']=="")
             {
                 if($Stateresult[0]['id']!="")
                 {
                        while($length > $i)
                         {
                           $result.="<option value='".$Stateresult[$i]['id']."'>".$Stateresult[$i]['name']."</option>"; 
                           $i++;
                         }
                 }       
             }
             else
              {
                 while($length > $i)
                         {
                            $result.="<option value='".$Stateresult[$i]['id']."'>".$Stateresult[$i]['name']."</option>"; 
                           $i++;
                         }
              }
            
            $result .= '</select>';
           
          /*if($ajexval=="usersignup")
           {  
               js("
                        if(document.getElementById('personalInfoValidation').value=='yes')
                           {
                       
                                frmvalidator.addValidation('state','dontselect=0','Please select State.'); 
                                 frmvalidator.addValidation('country','dontselect=0','Please select County.'); 
                          }
                          if(document.getElementById('shippingInfoValidation').value=='yes')
                          {
                              frmvalidator.addValidation('billing_country','dontselect=0','Please select shipping County.'); 
                              frmvalidator.addValidation('bllling_state','dontselect=0','Please select shipping State.'); 
                          }    
                   
                       "); 
              
               
           }
          else if($ajexval=="adminusersignup")
           { 
                   
                   if(MEMBER_USE_ADDRESS_INFO=='visible_required')
                   {  
                       js('
                           frmvalidator.addValidation("state","dontselect=0","Please select State."); 
                           frmvalidator.addValidation("country","dontselect=0","Please select County."); 
                       ');
                   } 
           }        */   
            
           
            echo  $result;
            exit;
            


    }


else if(isset($_POST['billing_country']))
 {    

     

        $a = $_POST['billing_country'];
       
        $lsValues = array();
        $users = new users_class();
        sleep(1);
        
        $result = "<select id='bllling_state' name='bllling_state' class=\"selectcss\">";
        $result.="<option value=''>select..</option>";
        $lTypes=null;
        
        //If Select is selected then
        if($a==0)
            $a=-1;
           
        $query= "SELECT id,name FROM ".TABLE_PREFIX."location where parentid=$a  and status=1 order by name asc";
           
        $Stateresult = $users->View($query);
        //$i = 1;
        $i = 0;
        $length=count($Stateresult);
        if($length==1 && $Stateresult[0]['id']=="")
         {
             if($Stateresult[0]['id']!="")
             {
                    while($length > $i)
                     {
                       $result.="<option value=".$Stateresult[$i]['id'].">".$Stateresult[$i]['name']."</option>"; 
                       $i++;
                     }
             }       
         }
         else
          {
             while($length > $i)
                     {
                       $result.="<option value=".$Stateresult[$i]['id'].">".$Stateresult[$i]['name']."</option>"; 
                       $i++;
                     }
          }
       
        
        $result .= '</select>';        
        
        echo $result;
        exit;
  
         
    }



?>
Return current item: MembersGear