I have two problems.
one is my ajax code does not work.
the other is I have an error in here.
document.getElementById("medicalid").innerHTML=xmlDoc.getElementsByTagName("hospital")[0].childNodes[0].nodeValue;
error says the value is null.
Would you please help how i can get the node value?
[ file name: medical.xsl ]
<script>
var xmlHttp
function showCustomer(str)
{
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
{
alert ("Your browser does not support AJAX!");
return;
}
var url='../stat/medical.html?patient_id=<xsl:value-of select="pid" />&medicalid='+str;
xmlHttp.onreadystatechange=stateChanged;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}
function stateChanged()
{
if (xmlHttp.readyState==4)
{
var xmlDoc=xmlHttp.responseXML.documentElement;
document.getElementById("medicalid").innerHTML=xmlDoc.getElementsByTagName("doctors")[0].childNodes[0].nodeValue;
}
}
function GetXmlHttpObject()
{
var xmlHttp=null;
try
{
// Firefox, Opera 8.0+, Safari
xmlHttp=new XMLHttpRequest();
}
catch (e)
{
// Internet Explorer
try
{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
}
return xmlHttp;
}
</script>
<table>
<tr>
<td>
<select id="medicalid" name="medicalid" onchange="return stateChanged()">
<xsl:for-each select="/document/stat/medical/hospital/medical">
<option value="{./@medical_field_id}"><xsl:value-of select="./@medical_field_name" /></option>
</xsl:for-each>
</select>
</td>
</tr>
<tr>
<td>
<select id="medicalfield" name="medicalfield" >
<xsl:for-each select="/document/stat/medical/doctors/doctor">
<option value="{./@doctorid}"><xsl:value-of select="./@doctor_name" /></option>
</xsl:for-each>
</select>
</td>
</tr>
</table>
[ file name: ../test/medical.xml ]
<document>
<testarea>
<stat>
<xsp:logic>
String medicalid=<xsp-request:get-parameter name="medicalid"/>';
</xsp:logic>
<medical>
<hospital>
<medical medical_field_id="PS" medical_field_name="Plastic Surgeory"></medical>
<medical medical_field_id="IM" medical_field_name="Internal Medicine"></medical>
<medical medical_field_id="OP" medical_field_name="Orthepedics"></medical>
</hospital>
<!-- if medicalid is null, it displays nothing, if medicalid is not null, it gets medicalid (get-parameter). -->
<doctors>
<doctor doctorid="MDPS" doctor_name="Test_2 M.D"></medical>
<doctor doctorid="MDPS" doctor_name="Test_1 M.D"></medical>
<doctor doctorid="MDPS" doctor_name="Test_3 M.D"></medical>
</doctors>
<medical>
<stat>
<testarea>
<document>
one is my ajax code does not work.
the other is I have an error in here.
document.getElementById("medicalid").innerHTML=xmlDoc.getElementsByTagName("hospital")[0].childNodes[0].nodeValue;
error says the value is null.
Would you please help how i can get the node value?
[ file name: medical.xsl ]
<script>
var xmlHttp
function showCustomer(str)
{
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
{
alert ("Your browser does not support AJAX!");
return;
}
var url='../stat/medical.html?patient_id=<xsl:value-of select="pid" />&medicalid='+str;
xmlHttp.onreadystatechange=stateChanged;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}
function stateChanged()
{
if (xmlHttp.readyState==4)
{
var xmlDoc=xmlHttp.responseXML.documentElement;
document.getElementById("medicalid").innerHTML=xmlDoc.getElementsByTagName("doctors")[0].childNodes[0].nodeValue;
}
}
function GetXmlHttpObject()
{
var xmlHttp=null;
try
{
// Firefox, Opera 8.0+, Safari
xmlHttp=new XMLHttpRequest();
}
catch (e)
{
// Internet Explorer
try
{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
}
return xmlHttp;
}
</script>
<table>
<tr>
<td>
<select id="medicalid" name="medicalid" onchange="return stateChanged()">
<xsl:for-each select="/document/stat/medical/hospital/medical">
<option value="{./@medical_field_id}"><xsl:value-of select="./@medical_field_name" /></option>
</xsl:for-each>
</select>
</td>
</tr>
<tr>
<td>
<select id="medicalfield" name="medicalfield" >
<xsl:for-each select="/document/stat/medical/doctors/doctor">
<option value="{./@doctorid}"><xsl:value-of select="./@doctor_name" /></option>
</xsl:for-each>
</select>
</td>
</tr>
</table>
[ file name: ../test/medical.xml ]
<document>
<testarea>
<stat>
<xsp:logic>
String medicalid=<xsp-request:get-parameter name="medicalid"/>';
</xsp:logic>
<medical>
<hospital>
<medical medical_field_id="PS" medical_field_name="Plastic Surgeory"></medical>
<medical medical_field_id="IM" medical_field_name="Internal Medicine"></medical>
<medical medical_field_id="OP" medical_field_name="Orthepedics"></medical>
</hospital>
<!-- if medicalid is null, it displays nothing, if medicalid is not null, it gets medicalid (get-parameter). -->
<doctors>
<doctor doctorid="MDPS" doctor_name="Test_2 M.D"></medical>
<doctor doctorid="MDPS" doctor_name="Test_1 M.D"></medical>
<doctor doctorid="MDPS" doctor_name="Test_3 M.D"></medical>
</doctors>
<medical>
<stat>
<testarea>
<document>