yes, but I can't use the body tag or anything above ... since for those i'm using a common php include. I've to call it somewhere inside the body.
Edit:
Well, I put it inside an image tag, but seems there's some problem somewhere ... it's not working as I want ...
Basically, this is a part of my ajax code that I want to execute
Code:
box = document.forms[0].nlone;
var age = document.getElementById('nlone').value;
<? if ($thisq!='') { ?>
if (age == '') {
age = <?=$thisq?>;
}
<? } ?>
var queryString = "?q=" + age + "&sid="+Math.random();
Means, I am trying to play with three conditions
1. If there is no $thisq (php variable) and no age (javascript variable), then load tha page normally
2. If there is $thisq but no age, make age = $thisq and execute the page
3. If there is age, irrespective of whether $thisq is set or not, execute the page
Now, when I am having the value of age, (ie, onchange in select), the function works as I want. However, when the page loads with a $thisq value, nothing happens.
Below is the full ajax code -
Code:
<script language="javascript" type="text/javascript">
<!--
//Browser Support Code
function ajaxFunction(){
var ajaxRequest; // The variable that makes Ajax possible!
try{
// Opera 8.0+, Firefox, Safari
ajaxRequest = new XMLHttpRequest();
} catch (e){
// Internet Explorer Browsers
try{
ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try{
ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e){
// Something went wrong
alert("Your browser broke!");
return false;
}
}
}
// Create a function that will receive data sent from the server
ajaxRequest.onreadystatechange = function(){
if(ajaxRequest.readyState == 4){
var ajaxDisplay = document.getElementById('ajaxDiv');
ajaxDisplay.innerHTML = ajaxRequest.responseText;
}
}
box = document.forms[0].nlone;
var age = document.getElementById('nlone').value;
<? if ($thisq!='') { ?>
if (age == '') {
age = <?=$thisq?>;
}
<? } ?>
var queryString = "?q=" + age + "&sid="+Math.random();
ajaxRequest.open("GET", "getlivra.php" + queryString, true);
ajaxRequest.send(null);
}
//-->
</script>
Bookmarks