My code is in the attachment alex.txt.

When i press the button for first time it gives me error: 'null' is null or not an object. But when i press it again or refresh the page and press the button it gives me the result that i expect.

When i change the var pdbfile1,2,3 values(for example with 2x4n;3gis;1crn) and press the button again there is the error again and i have to refresh the page again.

Can you please help me to to resolve this problem.

The code you posted returns the file you want

<AFPChain name1="2X4N.a" name2="3GYS.a" method="jFatCat_rigid" version="1.0" alnLength="187" blockNum="1" ... etc.

but Firefox reports

XML Parsing Error: no element found Location: moz-nullprincipal:{7ecb1187-1a21-4b63-bbc6-5b638a8a46d7} Line Number 1, Column 1:

^

The error 'null' is null or not an object may be the result of that or it may be something completely different; I can't tell without seeing more of the code.

IE8 is more forgiving.
It retrieves and parses the XML file without error, then writes 275 (the value of 'ca1Length') as expected.

Thank you so much for spending your time for me.

I'm using IE8 and it is still not working. Here is my all code. But please try puting different data for pdb1 and pdb 2 as
pdb1:3gys or "3D4X" or "3gis"
chain:a

pdb2:2x4n or "2QU0" or "1crn"
chain:a

and you will see that at first is not working and giving the error but when you click and unclick it will give the result.

To test here I would need
<script src="jmol/Jmol.js" type="text/javascript"></script>
and anything similar that is included in the page .

just delete the row. You do not need that file. Sorry!

and this is the deleteme.php /which is not so important/

Provided that the values 2X4N:a 3GYS:a are entered before the checkbox is clicked, this version of test page

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>


<meta http-equiv="Content-Type" content="text/html; charset=windows-1251" ;/>
<title></title>
</head>
<body>


<script language="javascript" type="text/javascript">


	function ajaxFunction1(z){
	var ajaxRequest1;  // The variable that makes Ajax possible!
	
	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest1 = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest1 = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest1 = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Your browser broke!");
				return false;
			}
		}
	}
	
		var t=z;
		
		
	// Create a function that will receive data sent from the server
	ajaxRequest1.onreadystatechange = function(){
		
		if(ajaxRequest1.readyState == 4){
			document.getElementById(t).innerHTML = ajaxRequest1.responseText;
			
	}

	}
	var wb_action = workbenchaction;
	var wb_pdb1 = document.getElementById('workbenchPDB1').value;
	var wb_chain1 = document.getElementById('workbenchChain1').value;
	var wb_pdb2 = document.getElementById('workbenchPDB2').value;
	var wb_chain2 = document.getElementById('workbenchChain2').value;
	var wb_url = "http://www.rcsb.org/pdb/workbench/workbench.do?action="+wb_action+"&mol="+wb_pdb1+"."+wb_chain1+"&mol="+wb_pdb2+"."+wb_chain2;
	
	var pdbfile=encodeURIComponent(document.getElementById("workbenchPDB1").value);
	var pdbfile1=encodeURIComponent(document.getElementById("workbenchPDB2").value);
	var pdbfile2=encodeURIComponent(document.getElementById("workbenchChain1").value);
	var pdbfile3=encodeURIComponent(document.getElementById("workbenchChain2").value);	
	
	
	
	ajaxRequest1.open("GET", "deleteme.php?wb_url="+wb_url+"&workbenchPDB1="+pdbfile+"&workbenchChain1="+pdbfile2+"&workbenchPDB2="+pdbfile1+"&workbenchChain2="+pdbfile3, true);
	ajaxRequest1.send(null); 
}


document.write("<div  align='center' style='width:32.3%; float:left; padding-top:5px; height:140px;   border:1px solid black; '>");
document.write("PDB1: <input type='text' name='workbenchPDB1' id='workbenchPDB1' size='4' maxlength='4'/>");
document.write("Chain: <input type='text' name='workbenchChain1' id='workbenchChain1' size='4' maxlength='1'>");
document.write("</div>");
document.write("<div  style='width:33%;height:145px; float:left;padding-left:6px;  border:1px solid black; '>");
document.write("<div align='left' style='width:49%;  height:145px; padding-left:4px;  float:left;  '>");
document.write("<div align='left' style='width:49%; height:145px;    float:right;   '>");
document.write("<input type='checkbox' id='option4'  value='pw_fatcat' onclick='pairwise(1);'>jFatCat_rigid<br>");
document.write("</div>");
document.write("<div align='center' style='width:33%; float:left; height:140px;  border:1px solid black;padding-top:5px; '>");
document.write("PDB2: <input type='text' name='workbenchPDB2'  id='workbenchPDB2' size='4' maxlength='4'/>");
document.write("Chain: <input type='text' name='workbenchChain2' id='workbenchChain2' size='4' maxlength='1'/>");
document.write("</div>");
document.close();
</script>


<div id='hide0'></div>

<div id='hide1' style="width:49%; float:left; background-color: #0C6"></div>

<div id='hide2' style="width:49%; float:left;  background-color: #F96"></div>

<div id='hide3' style="width:49%; float:left; background-color: #CF6"></div>

<div id='test' style=" width:49%;  float:left;"></div>

<div id='hide4' style=" width:100%;  float:left;">
<br />
<table align="center" style="text-align:center" id="alex">
<tr>
<td style="text-align:center" id='head'></td>
</tr>
<tr id="zaglavie" style="visibility:hidden";>
<td style="text-align:center">Structure alignment method</td>
<td style="text-align:center">P-value</td>
<td style="text-align:center">Equ</td>
<td style="text-align:center">RMSD</td>
<td style="text-align:center">Score</td>
<td style="text-align:center">Align-len</td>
<td style="text-align:center">Gaps</td>
<td style="text-align:center">Identity</td>
<td style="text-align:center">Similarity</td>
</tr>
<tr >
<td id='method'></td>
<td id='p_value'></td>
<td id='equ'></td>
<td id='rmsd'></td>
<td id='score'></td>
<td id='align-len'></td>
<td id='gaps'></td>
<td id='identity'></td>
<td id='similarity'></td>
</tr>

</table>
</div>



<script type="text/javascript">

 
function deleterow(z){
var row = document.getElementById(z);
row.parentElement.removeChild(row); 
}

function pairwise(checkbox) {
//Izxiskva se trusted sites i Miscellaneous > Access Data across domains > Enable.
	
var action;

if (checkbox == '1') {
    if (document.getElementById('option4').checked == true) {
        action = document.getElementById('option4').value
    }
    else {
        deleterow(document.getElementById('option4').value);
        return false;
    }
}
else if (checkbox == '2') {
    if (document.getElementById('option5').checked == true) {
        action = document.getElementById('option5').value
    }
    else {
        deleterow(document.getElementById('option5').value);
        return false;
    }
}
else if (checkbox == '3') {
    if (document.getElementById('option6').checked == true) {
        action = document.getElementById('option6').value
    }
    else {
        deleterow(document.getElementById('option6').value);
        return false;
    }
}
else if (checkbox == '4') {
    if (document.getElementById('option7').checked == true) {
        action = document.getElementById('option7').value
    }
    else {
        deleterow(document.getElementById('option7').value);
        return false;
    }
}
else return false;

var pdbfile = encodeURIComponent(document.getElementById("workbenchPDB1").value);
var pdbfile1 = encodeURIComponent(document.getElementById("workbenchPDB2").value);
var pdbfile2 = encodeURIComponent(document.getElementById("workbenchChain1").value);
var pdbfile3 = encodeURIComponent(document.getElementById("workbenchChain2").value);

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 && ajaxRequest.status == 200) {
        var xmlDoc = ajaxRequest.responseXML;
        var x = xmlDoc.getElementsByTagName("AFPChain")[0];

        var length_pdb1 = x.getAttribute("ca1Length");
        var length_pdb2 = x.getAttribute("ca2Length");

        document.getElementById('head').innerHTML = 'Structure Alignment Results for ' + pdbfile + '.' + pdbfile2 + ' length:' + length_pdb1 + ' vs. ' + pdbfile1 + '.' + pdbfile3 + ' length:' + length_pdb2;

        var body = document.getElementsByTagName("body")[0];

        // creates a <table> element and a <tbody> element
        var tbl = document.getElementById("alex");
        var tblBody = document.createElement("tbody");

        var row = document.createElement("tr");
        row.setAttribute("id", action);
        row.setAttribute("bgcolor", "cyan");

        // creating all cells
        var a = new Array();
        a[0] = x.getAttribute("method");
        a[1] = x.getAttribute("probability");
        a[2] = x.getAttribute("similarity2");
        a[3] = x.getAttribute("totalRmsdOpt");
        a[4] = x.getAttribute("alignScore");
        a[5] = x.getAttribute("alnLength");
        a[6] = x.getAttribute("gapLen");
        a[7] = x.getAttribute("identity") * 100;
        a[8] = x.getAttribute("similarity") * 100;
        for (var i = 0; i < 9; i++) {
            // Create a <td> element and a text node, make the text
            // node the contents of the <td>, and put the <td> at
            // the end of the table row
            var cell = document.createElement("td");
            var cellText = document.createTextNode(a[i]);
            cell.appendChild(cellText);
            row.appendChild(cell);
        }
        // add the row to the end of the table body
        tblBody.appendChild(row);
        // put the <tbody> in the <table>
        tbl.appendChild(tblBody);
        // appends <table> into <body>
        body.appendChild(tbl);
        // sets the border attribute of tbl to 2;
        tbl.setAttribute("border", "2");
    }
    else {
        //   alert("Error: returned status code " + ajaxRequest.status);
    }
}

ajaxRequest.open("GET", "http://www.pdb.org/pdb/workbench/getaligned.do?action=" + action + "&pdb1=" + pdbfile + "&chain1=" + pdbfile2 + "&pdb2=" + pdbfile1 + "&chain2=" + pdbfile3 + "&type=xml", true);

ajaxRequest.send();
}
</script>

</body>
</html>

returns what appear to be the desired values in a cyan row.

Do you get a different result?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.