why the value is not passed to my contrller page in codeigniter?

Posted by udaya on Stack Overflow See other posts from Stack Overflow or by udaya
Published on 2010-05-29T11:49:02Z Indexed on 2010/05/29 11:52 UTC
Read the original article Hit count: 212

Filed under:
|
|

Hi I am selecting state from country and city from state This is my select country Select box

<td width=""><select name="country" onChange="getState(this.value)" class="text_box_width_190">
        <option value="0">Select Country</option>
                <? foreach($country as $row) { ?>
                <option value="<?=$row['dCountry_id']?>"><?=$row['dCountryName']?></option>
                <? } ?>
</select></td>

This is my select state select box

<select name="state" id="state" class="text_box_width_190" >
            <option value="0">Select State</option>
            </select>

This is my select city selectbox

<td width=""><div id="citydiv"><select name="city" class="text_box_width_190">
            <option>Select City</option>
            </select></div></td>

this is my script

<script type ="text/javascript">
function getXMLHTTP() { //fuction to return the xml http object
        var xmlhttp=false;  
        try{
            xmlhttp=new XMLHttpRequest();
        }
        catch(e)    {       
            try{            
                xmlhttp= new ActiveXObject("Microsoft.XMLHTTP");
            }
            catch(e){
                try{
                xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
                }
                catch(e1){
                    xmlhttp=false;
                }
            }
        }

        return xmlhttp;
    }

    function getState(countryId) {      

        var strURL="http://localhost/ssit/system/application/views/findState.php?country="+countryId;
        var req = getXMLHTTP();

        if (req) {

            req.onreadystatechange = function() {
                if (req.readyState == 4) {
                    // only if "OK"
                    if (req.status == 200) {                        
                        document.getElementById('statediv').innerHTML=req.responseText;                     
                    } else {
                        alert("There was a problem while using XMLHTTP:\n" + req.statusText);
                    }
                }               
            }           
            req.open("GET", strURL, true);
            req.send(null);
        }       
    }
    function getCity(countryId,stateId) {       
        var strURL="http://localhost/ssit/system/application/views/findCity.php?country="+countryId+"&state="+stateId;
        var req = getXMLHTTP();

        if (req) {

            req.onreadystatechange = function() {
                if (req.readyState == 4) {
                    // only if "OK"
                    if (req.status == 200) {                        
                        document.getElementById('citydiv').innerHTML=req.responseText;                      
                    } else {
                        alert("There was a problem while using XMLHTTP:\n" + req.statusText);
                    }
                }               
            }           
            req.open("GET", strURL, true);
            req.send(null);
        }

    }
</script>

This is my findstate page

<? $country=intval($_GET['country']);
$link = mysql_connect('localhost', 'root', ''); //changet the configuration in required
if (!$link) {
    die('Could not connect: ' . mysql_error());
}
mysql_select_db('ssit');
$query="Select dStateName,dState_id FROM tbl_state Where dCountry_id='1'";
$result=mysql_query($query);

?>
<select name="state" onchange="getCity(<?=$country?>,this.value)">
<option value="0">Select State</option>
<? while($row=mysql_fetch_array($result)) { ?>
<option value=<?=$row['dState_id']?>><?=$row['dStateName']?></option>
<? } ?>
</select>

This is my find city page

<? $countryId=intval($_GET['country']);
$stateId=intval($_GET['state']);
$link = mysql_connect('localhost', 'root', ''); //changet the configuration in required
if (!$link) {
    die('Could not connect: ' . mysql_error());
}
mysql_select_db('ssit');
$query="Select dCityName,dCity_id FROM tbl_city Where dState_id='30'";
$result=mysql_query($query);

?>
<select na

me="city"> Select City when i post country i can receive it but i cant receive my state and city How to receive it

© Stack Overflow or respective owner

Related posts about php

Related posts about list