Hi friends,

As i have one form having Country and State combo box. Depend on
country selected it will
Fill up States automatically.

Here is my Code :
// file :  edit.thtml

//calling ajax functions
function getstates(st)
{
        country = $('country_name').value;
        alert(country);
        if(!country)
                $('mystatelist').innerHTML = '<select id="state_name"
name="data[User][state_name]" disabled><option>Select</option></
select>';
        else
        {
                url = root+'admin/users/update_select/?country='+country
+'&state='+st;
                //alert(url);
                new 
Ajax.Request(url,{method:"get",onSuccess:function(transport){
                $('mystatelist').innerHTML = '<select id="state_name"
name="data[User][state_name]">'+transport.responseText+'</select>';
                //alert(transport.responseText);
                        },onFailure:function(){alert('Failed to get 
states');}});
        }
}

=============================================
Country and State Code :

<?php

                                         //pr($this->data); die;
                                         //$countries[0]='Select';
                                         //pr($countries); die;
                                         foreach($countries as $key=>$value)
                                         {
                                                        $countri[$value]=$value;
                                         }

                                         $carr=array(''=>'Select');
                                         $countri =  
array_merge($countri,$carr);
                                         ksort($countri);
                                         
$countrybill=$this->data['User']['Country'];

                                        // $selected = mystate;

                        ?>
                <td colspan="2">
                                                <?php echo 
$html->selectTag('User/country_name', $countri ,
$countrybill,
                                         
array('id'=>'country_name','onchange'=>'getstates()'), array(),
false);?>               </td>
    </tr>
    <tr>
      <td valign="top"><strong>State/Province</strong></td>
      <td colspan="2"> <span id="mystatelist">
                                                <select id="state_name" 
name="data[User][state_name]" disabled>
                                                        <option>Select</option>
                                                </select>
                                        </span>                                 
</td>
    </tr>

===================================
Now please tell me what is the problem.... ??
Country is filled up from database table countries
but after selecting country  STATE combo is not filled up.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to