Witam.

Mam formularz w którym pole select z miastami, gdzie po wybraniu regionu ładuje się dynamicznie za pomocą Ajax.
Nie wiem dlaczego formularz nie przesyła wybranej opcji z pola select (miasta), w ogóle nic nie przesyła tak jakby tego pola nie było.

Dodam, że przed wybraniem regionu, pole select (miasta) jest ładowane przez php z domyślnymi opcjami i w momencie wysłania dane z niego są przesyłane.

Kod formularza:
<form action="?" method="get" id="CountryForm" name="CountryForm" style="border:none" onSubmit="nieaktywne();">
  1. <?php $db = & JFactory::getDBO(); ?>
  2. <div class="htl-box-parm-title"><span>Kraj: </span></div>
  3. <div class="htl-box-parm-select">
  4. <?php
  5. $query = 'SELECT c.id AS value, c.name AS text'
  6. . ' FROM #__hg_countries AS c'
  7. . ' LEFT JOIN #__hg_hotelitems AS i ON i.country = c.id'
  8. . ' WHERE c.id ='.$this->country->id
  9. . ' AND i.country > 0'
  10. . ' AND c.published = 1'
  11. . ' GROUP BY c.name ASC'
  12. ;
  13.  
  14. $db->setQuery( $query );
  15. $result = $db->loadObjectList();
  16.  
  17. $Selected = explode(",", $this->country->id );
  18.  
  19. $kraj = JHTML::_('select.genericlist', $result, 'kraj', 'class="inputbox" size="1"', 'value', 'text', $Selected);
  20.  
  21. echo $kraj;
  22. ?>
  23. </div>
  24. <div class="htl-box-parm-title"><span>Region: </span></div>
  25. <div class="htl-box-parm-select">
  26. <?php
  27. $query = 'SELECT c.id AS value, c.name AS text'
  28. . ' FROM #__hg_states AS c'
  29. . ' WHERE country ='.$this->country->id
  30. . ' ORDER BY text ASC'
  31. ;
  32.  
  33. $db->setQuery( $query );
  34. $result = $db->loadObjectList();
  35.  
  36. $Selected = explode(",", $_GET['region'] );
  37.  
  38. $regiony[] = JHTML::_('select.option', 0, JText::_('wszystkie regiony') );
  39. $regiony = @array_merge($regiony, $result);
  40. $javascript = 'onChange="ChangeCity(this.value)"';
  41. $regiony = JHTML::_('select.genericlist', $regiony, 'region', 'class="inputbox" size="1"' . $javascript, 'value', 'text', $Selected);
  42.  
  43. echo $regiony;
  44. ?>
  45. </div>
  46. <div class="htl-box-parm-title"><span>Miasto: </span></div>
  47. <div class="htl-box-parm-select">
  48. <div id="AjaxMiasto">
  49. <?php
  50. $where = ' WHERE c.country = '.$this->country->id;
  51. if ($_GET['region']) {
  52. $where .= ' AND c.states = '.$_GET['region'];
  53. }
  54.  
  55. $query = 'SELECT c.id AS value, c.name AS text'
  56. . ' FROM #__hg_cities AS c'
  57. .$where
  58. . ' ORDER BY text ASC'
  59. ;
  60.  
  61. $db->setQuery( $query );
  62. $result = $db->loadObjectList();
  63.  
  64. $Selected = explode(",", $_GET['miasto'] );
  65.  
  66. $miasto[] = JHTML::_('select.option', 0, JText::_('Wszystkie miasta') );
  67. $miasto = @array_merge($miasto, $result);
  68. $miasto = JHTML::_('select.genericlist', $miasto, 'miasto', 'class="inputbox" size="1"', 'value', 'text', $Selected);
  69.  
  70. echo $miasto;
  71. ?>
  72. </div>
  73. <input type="submit" value="wyślij";/>
  74. </div>
  75. <div id="htl-parm-filter">
  76. <div class="htl-box-parm-title"><span>Wyżwienie: </span></div>
  77. <div class="htl-box-parm-select">
  78. <?php
  79. echo hgSelectHelper::wyzywienie(JRequest::getVar('wyzywienie[]', ''));
  80. ?>
  81. </div>
  82. <div class="htl-box-parm-title"><span>Rodzaj zakwaterowania: </span></div>
  83. <div class="htl-box-parm-select">
  84. <?php
  85. echo hgSelectHelper::SelectRoomFacilities(JRequest::getVar('type_search[]', ''));
  86. ?>
  87. </div>
  88. <input type="submit" value="wyślij";/>
  89. </div>
  90. </form>
  91.  


Kod Ajaxa (ChangeCity):
Kod
function ChangeCity(a){
$('AjaxMiasto').setHTML('<div class="inputbox-img"><span>Wczytywanie danych</span><img src="images/ajax_loader.gif"></div>');
var url = '<?php echo JURI::base();?>index.php?option=com_hotelguide&format=raw&amp;task=ChangeCity';
var ajax = new Ajax(url, {
    method: 'get',
    update: $('AjaxMiasto'),
    data: 'region='+a+'&kraj=<?php echo $this->country->id ?>'
    });
          ajax.request.delay(50, ajax);
}

function uncheckAll(name)
{
    var ele = 'wyzywienie[]';
    if (name != true) {
        ele = 'wyzywienie[]';
    }
    var theForm = document.CountryForm;
    for (i=0; i<theForm.elements.length; i++) {
        if (theForm.elements[i].name==ele && theForm.elements[i].value > 0)
            theForm.elements[i].checked = false;
    }
}

function uncheck(name)
{
    var ele = 'wyzywienie[]';
    if (name != true) {
        ele = 'wyzywienie[]';
    }
    var theForm = document.CountryForm;
    for (i=0; i<theForm.elements.length; i++) {
        if (theForm.elements[i].name==ele && theForm.elements[i].value == -1 && theForm.elements[i].checked == true)
            theForm.elements[i].checked = false;
    }
}
function nieaktywne() {
   form = document.forms['CountryForm'];
    if(form.elements['region'].value == '0') { form.elements['region'].disabled = "true"; }
    if(form.elements['filter_order'].value == '') { form.elements['filter_order'].disabled = "true"; }
    if(form.elements['filter_order_Dir'].value == '') { form.elements['filter_order_Dir'].disabled = "true"; }
}


Stronka postawiona na cms joomla 1.5.22

Pozdrawiam