Jump to content

Aviway

Members
  • Posts

    37
  • Joined

  • Last visited

Posts posted by Aviway

  1. what part are you having trouble with? I don't see any Javascript in there. What have you tried? What are you stuck on?
    function change_city(area_id){document.getElementById('city_loader').style.display='block';var xmlhttp;   if (window.XMLHttpRequest){  // code for IE7+, Firefox, Chrome, Opera, Safari  xmlhttp=new XMLHttpRequest();}else{  // code for IE6, IE5  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");}xmlhttp.onreadystatechange = function(){  if (xmlhttp.readyState==4 && xmlhttp.status==200)  {   var result = xmlhttp.responseText;   if (result)    document.getElementById('city_loader').style.display='none';       document.getElementById('error_log').innerHTML='PROBLAM!';  }}xmlhttp.open("GET","pages/update/change_city_by_area.php?area_id="+encodeURIComponent(area_id),true);xmlhttp.send(null);}

    This is the function that call with "onclick" event. My problam is how to include the array that I'm returned from "change_city_by_area.php", inside the other SELECT TAG(city). I use this ajax code for a lot of things but i never used it to get response with array.

  2. Hello,I need help writing a code in AJAX. I have a form where you had to choose an area in the country,and after selecting the regionin the country,another SELECT tag will only see the cities that are in the selected area.The PHP\HTML code:

    <select id="area" name="area"><?phpforeach ($get_all_area as $key => $val){  echo '<option onclick="change_city('.$val['area_id'].')" value="'.$val['area_id'].'">'.$val['area_name'].'</option>';}?></select> ]<select id="city" name="city"><!-- All cities are in the selected area --></select> 

×
×
  • Create New...