EDIT:
I get it!!
Thanks!
Hi
,
I have a 3 tables (country, state, city and myTable) and I'm trying to show on "myTable" the correct city and state depending (filtering) of a country selected.
As sample please see the following data from my tables:
country
- USA
- Canada
- Mexico
state
- Nueva York
- Hidalgo
- Sonora
city
- Nueva York
- Bronx
- Jalisco
I want show in the form the current state and city of each country selected.
If I select USA (as country) I need to see Nueva York (on state) and when I select Nueva York I need see Bronx and Nueva York (as city).
Sorry for my complex or incomplete explanation...
I'm working with a JavaScript code (of a friend):
function obtiene_http_request()
{
var req = false;
try
{
req = new XMLHttpRequest(); /* p.e. Firefox */
}
catch(err1)
{
try
{
req = new ActiveXObject("Msxml2.XMLHTTP");
/* algunas versiones IE */
}
catch(err2)
{
try
{
req = new ActiveXObject("Microsoft.XMLHTTP");
/* algunas versiones IE */
}
catch(err3)
{
req = false;
}
}
}
return req;
}
var miPeticion = obtiene_http_request();
//***************************************************************************************
function from(id,ide,url){
var mi_aleatorio=parseInt(Math.random()*99999999);//para que no guarde la página en el caché...
var vinculo=url+"?id="+id+"&rand="+mi_aleatorio;
//alert(vinculo);
miPeticion.open("GET",vinculo,true);//ponemos true para que la petición sea asincrónica
miPeticion.onreadystatechange=miPeticion.onreadystatechange=function(){
if (miPeticion.readyState==4)
{
//alert(miPeticion.readyState);
if (miPeticion.status==200)
{
//alert(miPeticion.status);
//var http=miPeticion.responseXML;
var http=miPeticion.responseText;
document.getElementById(ide).innerHTML= http;
}
}/*else
{
document.getElementById(ide).innerHTML="<img src='ima/loading.gif' title='cargando...' />";
}*/
}
miPeticion.send(null);
}
I need implement this code in JDom or use JFactory::getDBO(); the best way. I hope you can help me. Thanks in advance.
In this moment i'm changing the following:
<?php echo JDom::_('html.form.input.ajax', array(
'dataKey' => 'countryid',
'dataObject' => $this->estadio,
'ajaxContext' => 'soefutbol.paises.ajax.groupby25',
'domClass' => "validate[required]",
'required' => true,
'validatorMsgInfo' => "SOEFUTBOL_VALIDATOR_COUNTRY_ERROR",
'ajaxVars' => array('values' => array(
$this->estadio->countryid
))
));
?>
For this code:
<?php
$db =& JFactory::getDBO();
$query = "SELECT * FROM #__soefutbol_paises";
$db->setQuery($query);
$result = $db->loadObjectList();
?>
<select name="countryid" onchange="from(document.adminForm.countryid.value,'ciudad','components/com_soefutbol/requeridos/ciudad.php')" id="countryid" data-validation-engine="validate[required]" id="countryid" style="border-left:3px red solid;">
<option value="">- País -</option>
<?php
foreach ($result as $row)
{
?>
<option value="<?php echo $row->id;?>"><?php echo $row->country;?></option>
<?php
}
?>
When I select the country the function is called: onchange="from(document.adminForm.countryid.value,'ciudad','components/com_soefutbol/requeridos/ciudad.php')"
And the ID form the DIV "ciudad" is changed by the contend of ciudad.php
But when I try to modify something i can't see the element saved in this case I only can see "- País -"...
Please help.