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

 

Link to comment
Share on other sites

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.