asked on
for ( pai in idsAry )
{
sid = idsAry[pai];
// button = "<input type=button style='border: 0px;' id='button" + sid + "' value='+' border='0' onclick=checkPriors('" + sid + "')>";
button = "<img src='images/report-icon.gif' id='button" + sid + "' border='0' onclick=checkPriors('" + sid + "')>";
/*if (/msie/i.test(navigator.userAgent)) //only overide IE
{
//alert("IT WORKED");
document.nativeGetElementById = document.getElementByID;
document.getElementById = function(id)
{
var elem = document.nativeGetElementById(id);
if(elem)
{
//make sure that it is a valid match on id
if(elem.attributes['id'].value == id)
{
return elem;
//alert("it worked");
}
else
{
//otherwise find the correct element
for(var i=1;i<document.all[id].length;i++)
{
if(document.all[id][i].id == id)
{
return document.all[id][i];
}
}
}
}
return null;
};
}*/
document.getElementById(sid).innerHTML = button;//debugger breaks here after the page refreshes
ASKER
<script type="text/javascript">
var httpRequest;
var index;
var mapsign;
var studyIsReady = true;
var maxpriors = 0;
//bug workaround for document.getElementById and getAttributes (doesn't work in ie)
//overrides the IE getElementById with nativeGetElementById and then searches the document for the correct id
/*function nativeGetElementById(sid)
{
if (/msie/i.test(navigator.userAgent)) //only overide IE
{
//alert("IT WORKED");
document.nativeGetElementById = document.getElementByID;
document.getElementById = function(id)
{
var elem = document.nativeGetElementById(id);
if(elem)
{
//make sure that it is a valid match on sid
if(elem.attributes['id'].value == id)
{
return elem;
//alert("it worked");
}
else
{
//otherwise find the correct element
for(var i=1;i<document.all[id].length;i++)
{
if(document.all[id][i].id == id)
{
return document.all[id][i];
}
}
}
}
//alert("it didn't work");
}
}
}
*/
function sendStudies(studiesStr) {
maxpriors++
if (maxpriors < 50) {
if (typeof XMLHttpRequest != "undefined"){
httpRequest = new XMLHttpRequest();
} else if (window.ActiveXObject){
httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
}
httpRequest.onreadystatechange = receivePriors;
httpRequest.open('GET', 'https://MYWEBSITE/add_prior_buttons.php?studies=' + studiesStr, true); //also debugger broke here
httpRequest.send(null);
}
}
function receivePriors() {
if (httpRequest.readyState == 4){
if (httpRequest.status == 200){
var idsStr = httpRequest.responseText;
// Split retrieved string into an array.
var idsAry = new Array();
idsAry = idsStr.split("-");
// displayPriors(idsAry);
// Then loop through the array to insert a button into the corresponding span id.
var pai = 0;
for ( pai in idsAry )
{
sid = idsAry[pai];
// button = "<input type=button style='border: 0px;' id='button" + sid + "' value='+' border='0' onclick=checkPriors('" + sid + "')>";
button = "<img src='images/report-icon.gif' id='button" + sid + "' border='0' onclick=checkPriors('" + sid + "')>";
/*if (/msie/i.test(navigator.userAgent)) //only overide IE
{
//alert("IT WORKED");
document.nativeGetElementById = document.getElementById;
document.getElementById = function(id)
{
var elem = document.nativeGetElementById(id);
if(elem)
{
//make sure that it is a valid match on id
if(elem.attributes['id'].value == id)
{
return elem;
//alert("it worked");
}
else
{
//otherwise find the correct element
for(var i=1;i<document.all[id].length;i++)
{
if(document.all[id][i].id == id)
{
return document.all[id][i];
}
}
}
}
return null;
};
}*/
document.getElementById(sid).innerHTML = button;//debugger broke here
}
} else {
// alert('There was a 200 problem');
}
} else {
// alert('There was a 4 problem');
return 0;
}
}
/*************************************************************************
This function inserts a button (value='+') into the HTML of the
corresponding span id.
**************************************************************************/
function displayPriors(priorsArray) {
var pai = 0;
for ( pai in priorsArray )
{
button = "<input type=button id='button" + priorsArray[pai] + "' value='+' onclick=checkPriors('" + priorsArray[pai] + "')>";
//if(/msie/i.test (native.userAgent))
document.getElementById(priorsArray[pai]).innerHTML = button;
}
}
function checkPriors(studyid){
// set the row index
index = studyid;
row = document.getElementById("row" + studyid);
// if the study is expanded, set button value to '-'
if (row.style.display == "none"){
row.style.display = "";
document.getElementById('button' + studyid).value = "-";
} else {
// else set it to '+'
row.style.display = "none";
document.getElementById('button' + studyid).value = "+";
}
if (typeof XMLHttpRequest != "undefined"){
httpRequest = new XMLHttpRequest();
} else if (window.ActiveXObject){
httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
}
// httpRequest.overrideMimeType('text/xml');
httpRequest.open('GET', 'https://MYWEBSITE/prior_reports.php?studyId=' + studyid, true);
httpRequest.onreadystatechange = callback;
httpRequest.send(null);
}
function callback(){
if (httpRequest.readyState == 4){
if (httpRequest.status == 200){
document.getElementById("priors"+index).innerHTML = httpRequest.responseText;
} else {
// alert('There was a 200 problem');
}
} else {
// alert('There was a 4 problem');
}
}
ASKER
PHP is a widely-used server-side scripting language especially suited for web development, powering tens of millions of sites from Facebook to personal WordPress blogs. PHP is often paired with the MySQL relational database, but includes support for most other mainstream databases. By utilizing different Server APIs, PHP can work on many different web servers as a server-side scripting language.
TRUSTED BY