Hello all,
I'm trying to get a page changed over from synchronous form submits to asynchronous (AJAXified) ones. I am very new to AJAX, but from the numerous tutorials I've read, this should be a very easy task.
The following is a select that I've prepopulated with values through simple PHP code:
CODE
<form name="fixform">
.
.
.
<select name="select1">
<option value="<?php $range[0] = 0; echo $range[0];?>" title="One day">One Day</option>
<option value="<?php $range[1] = 1; echo $range[1];?>" title="Three days">Three days</option>
<option value="<?php $range[2] = 2; echo $range[2];?>" title="One week">One week</option>
<option value="<?php $range[3] = 3; echo $range[3];?>" title="Two weeks">Two weeks</option>
</select>
.
.
.
The PHP this code will be acting on:
CODE
$biggestIndex = "";
switch($_GET['select1'])
{
case '0':
$biggestIndex = 2;
break;
case '1':
$biggestIndex = 8;
break;
case '2':
$biggestIndex = 20;
break;
case '3':
$biggestIndex = 41;
break;
default:
break;
}
My objective is to use the $_GET['select1'] variable to change the switch() statement shown in the second block of code in this manner:
-page loads, brings up something basically blank excepting the select.
-I choose a value of the select, and as soon as I click that value, a picture corresponding to the value of $biggestIndex (chosen through the switch() statement) posts in a div that I've specified.
My XMLHTTPRequest is taken directly from the w3schools.com AJAX tutorial and modified to reflect my variables. I would hope (by virtue of it being on a well-known site like that) that it is correct.
The XMLHTTPRequest:
CODE
function ajaxFunction()//stuff to start XMLHTTPRequest object for the AJAX'd RIPE0 KCore changes
{
var xmlHttp;
try
{
// Firefox, Opera 8.0+, Safari
xmlHttp=new XMLHttpRequest();
}
catch (e)
{
// Internet Explorer
try
{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
try
{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e)
{
alert("Your browser does not support AJAX!");
return false;
}
}
}
xmlHttp.onreadystatechange=function()
{
if(xmlHttp.readyState==4)
{
document.fixform.select1.value=xmlHttp.responseText;
}
}
xmlHttp.open("GET","index.php",true);
xmlHttp.send(null);
}
To this end, I've tried troubleshooting this by setting variables to check and see if $_GET is being populated...to no avail.
Any ideas on what could be the problem? Thanks for all your help.
NLC