Welcome Guest, Not a member yet? Register   Sign In
Please help me with the last dropdown (select box) appear correctly, actual it show page in page
#1

[eluser]Unknown[/eluser]
Hello to all, i apologize for my english, am new to codeigniter and biginner in php, i have a project for my college degree and i stuck to this problem.
I have two select box (dropdown), the first select box (dropdown) show Romanian counties and the last select box (dropdown) will have to show the localities related to selected county (from the first select box).
When i select a county in the first select box the last select box shows me the related localities from the selected county and the whole page again (page in page).

This is my code:
- the ajax code
Code:
function ajaxRequest()
{
var xmlhttp=false;
// Attempt to initialize xmlhttp object
try{
  xmlhttp=new XMLHttpRequest(); // code for IE7+, Chrome, Opera 8.0+, Firefox, Safari
}
catch(e){  
  try{  
   xmlhttp= new ActiveXObject("Microsoft.XMLHTTP"); // code for IE6, IE5
  }
  catch(e1){
   try{
    xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); // code to use different activex object
   }
   catch(e2){
    xmlhttp = false;
   }
  }
}

// If not initialized, create XMLHttpRequest object
if (!xmlhttp)
{
  alert("Acest browser nu suporta AJAX.");
  return null;
}

return xmlhttp;
}

function selectJud(param)
{
var xmlhttp = ajaxRequest();

xmlhttp.onreadystatechange=function()
   {
   if (xmlhttp.readyState==4 && xmlhttp.status==200)
     {
     document.getElementById("id_test")[removed]=xmlhttp.responseText;
     }
   };
  
xmlhttp.open("GET","/licenta/turisti?select_jud="+param, true);
xmlhttp.send(null);
}

- the controller code (turisti.php)
Code:
function index()
{
  $this->load->model('turisti_model');
  
  $rezultat_jud = $this->turisti_model->getAllJudete();
  $judete = array(''=>'Selecteaza judetul...');
  $localitati = array(''=>'Selecteaza localitatea...');
  
  foreach ($rezultat_jud as $key => $row)
  {
   $key = $row['initialajud'];
   $judete[$key] = $row['numejud'];
  }
  $data['sel_jud'] = $judete;
  
  if (isset($_GET['select_jud']))
  {
   $initialajudet = $this->input->get('select_jud',TRUE);
   $rezultat_loc = $this->turisti_model->getLocalitateByInitialaJudet($initialajudet);
  
  
   foreach ($rezultat_loc as $key => $row)
   {
    $key = $row['numeloc'];
    $localitati[$key] = $row['numeloc'];
   }
  
   $data['sel_loc'] = $localitati;
  
   $this->load->view('inc/judete_view',$data);
  }
    
  $data['sel_loc'] = $localitati;
  
  $this->template->view('turisti_view', $data);
}
- the view code (turisti_view.php)
Code:
<?php
//first select box
$js_jud = 'id="select_jud" onchange="selectJud(this.value);"';
echo form_dropdown('select_jud', $sel_jud, set_select('select_jud',$sel_jud,TRUE), $js_jud);
echo '<span class="obligatoriu">*</span> <p class="exemplu">Alege judetul...</p> <br />';
  
//last select box
$js_loc = 'id="select_loc"';
echo '<span id="id_test">';
echo form_dropdown('select_loc', $sel_loc, set_select('select_loc',$sel_loc,TRUE), $js_loc);
echo '</span>';
?&gt;

- the view code (judete_view.php)
Code:
&lt;?php
$js_loc = 'id="select_loc"';
echo form_dropdown('select_loc', $sel_loc, set_select('select_loc',$sel_loc,TRUE), $js_loc);
?&gt;

Where i'm wrong?
If you want to better understand the problem, what it can put printscreens.
#2

[eluser]Unknown[/eluser]
I put 2 printscreen to better understand the problem.

- the first printscreen - http://postimage.org/image/7npnwozbb/
- the last printscreen - http://postimage.org/image/6qs0jbt0r/

The first printscreen it show the form with are two dropdown (select box) and the first dropdown is not selected.
The second printscreen it show the problem that i spoke, it show page in page.

Where is the problem that show page in page?




Theme © iAndrew 2016 - Forum software by © MyBB