Jump to content

Need Ajax multi form option value request help.


rilana

Recommended Posts

Hi everyone, I am trying to change my existing php mysql script to something more exiting and up to date. http://neu.smartpersonal.ch/stellen.php so far the I was able with researches to complete a ajax request with a Button, but I would like to do the refresh on change so I would not need a button. But somehow I cant get it to work. I would aprechiate any help.

 

Here is what I have:

 

HTML

<form>
<select name="kategorie" id="kategorie">
<option value="">Kagegorie wählen:</option>
<option value="1" />Technische Berufe</option>
<option value="3" />Bau</option>
<option value="4" />Verkauf</option>
<option value="2" />Kaufmännische Berufe</option>
</select>

                                    

<select name="region" id="region">
<option value="1,2,4,5,">Region wählen:</option>
<option value="1" />Linkes Seeufer</option>
<option value="2" />Rechtes Seeufer</option>
<option value="4" />Zürich Oberland</option>
<option value="5" />Zürich</option>
</select>
<input type='button' value='Refresh Data' onclick="showUser(document.getElementById('kategorie').value,document.getElementById('region').value)">
</form>

 

the javascript:

var xmlhttp;

function showUser(str,region)
{
xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
  {
  alert ("Browser does not support HTTP Request");
  return;
  }
var url="stellenResult.php";
url=url+"?q="+str+"&a="+region;
url=url+"&sid="+Math.random();
xmlhttp.onreadystatechange=stateChanged;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}

function stateChanged()
{
if (xmlhttp.readyState==4)
{
document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
}
}

function GetXmlHttpObject()
{
if (window.XMLHttpRequest)
  {
  // code for IE7+, Firefox, Chrome, Opera, Safari
  return new XMLHttpRequest();
  }
if (window.ActiveXObject)
  {
  // code for IE6, IE5
  return new ActiveXObject("Microsoft.XMLHTTP");
  }
return null;
}

 

Thank you for helping. Rilana

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.