Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1

TOPIC:

[SOLVED] Dynamic Select - Please help 11 Sep 2012 17:37 #3523

EDIT:

I get it!! :woohoo:

Thanks!





Hi :blush: ,

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. :blink:

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. :(

Please Log in or Create an account to join the conversation.

Last edit: by admin.
  • Page:
  • 1
Time to create page: 0.047 seconds
  I still don't believe he can really be human to do all this ! From all of the forums that I've ever participated in this is certainly the one that most encapsulates the feeling of being truly open source where everyone's opinions and contributions can and will shape the development of the service! It's truly awesome! Hope you enjoy cooking and look forward to reading and contributing to any of the editorial work that you proposed too!! Thanks
Gez (audibleid - JED)

Get Started