Jump to content

Recommended Posts

i have the following code

the get country_id ajax is  executing the div as a test correctly

how would i insert the result as a var in this line:

setAutoComplete("searchField", "results", "../ajax_autocomplete/autocomplete_test.php?country_id=[iNSERT VAR]&part=");

//need to insert the country_id
<script type="text/javascript">
var selected_from_list = false;
$(function(){
    setAutoComplete("searchField", "results", "../ajax_autocomplete/autocomplete_test.php?country_id=&part=");
});

//this working code:
<script type="text/javascript">
function ajaxfunction(str)
{
if (str=="")
  {
  document.getElementById("country_id").innerHTML="";
  return;
  }
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)
    {
    document.getElementById("country_id").innerHTML=xmlhttp.responseText;
    }
  }
  var testVars = '';	
testVars = 'c='+country_id;
xmlhttp.open("GET","getCountry_idfunc.php?country_id="+str,true);
xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xmlhttp.send(testVars); 
return false;

xmlhttp.send();
}

</script>


</script>

 

yes I need to dive into ajax

thanks

ok some progress revised code

the response is

country_id undefined

 

<script type="text/javascript">


function ajaxfunction(str)
{
if (str=="")
  {
  document.getElementById("country_id").innerHTML="";
  return;
  }
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 id = document.getElementById("cid").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","getCountry_idfunc.php?country_id="+str,true);
xmlhttp.send();
}
var selected_from_list = false;

var u =document.getElementById("cid").innerHTML.id;
$(function(){
    setAutoComplete("searchField", "results", "../ajax_autocomplete/autocomplete_test.php?country_id="+u+"&part=");
});
</script>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.