Thanks serversphere, I'm familiar that page quite a bit! ;)
Anyway, I manage to get some help from another page and here's result. (if someone needs?!)
Ajax.js:
Code:
var rdiv;
var xmlHttp;
var cb;
function request (url, div, parameters, callback)
{
if(xmlHttp)
{
//alert("aboting current xmlhttp");
//xmlHttpd.abort();
}
rdiv = div;
var queryString = url + "?" + parameters;
cb = callback;
createXMLHttpRequest();
xmlHttp.onreadystatechange = handleStateChange;
xmlHttp.open("GET", queryString, true);
xmlHttp.send(null);
}
function createXMLHttpRequest()
{
if(window.ActiveXObject)
{
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
else if (window.XMLHttpRequest)
{
xmlHttp = new XMLHttpRequest();
}
}
function handleStateChange()
{
if(xmlHttp.readyState == 4)
{
if(xmlHttp.status == 200)
{
parseResults();
}
}
}
function parseResults()
{
document.getElementById(rdiv).innerHTML = xmlHttp.responseText;
if(cb) cb();
}
Code:
function fetchQueryPage(pid)
{
request("/doquery.php", "doquery_box", "id=" + pid)
}
Place div whit class name "doquery_box" page where you are using this. And call fetchQueryPage function onClick event in your radio buttons.
Code:
<input type="radio" name="myradio" onClick="fetchQueryPage(11);" />
and finally, in doquery.php you have your code ie.
PHP Code:
$pid = $_GET['id'];
$q = mysql_query("SELECT result FROM table WHERE id = '$pid'") or die(mysql_error());
$do = mysql_fetch_array($q);
print("Here is your result:" . $do['result']);
Ok.. I'm happy now when finally got it BUT, now I have different problem.
How can I define that if one of those radio buttons are already checked when user arrive that page, then run that fetchQueryPage function?
Because I have option on different page when user can choose one of those radios.
Code:
if (radio.[i].checked == true)
{
run that function whit that pid
}
else
{
wait while user clicks one of those radios
}
Thanks for all help! =)