Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

input text and javascript

Status
Not open for further replies.

bbvic

Technical User
Oct 21, 2004
51
US
how to add
<input type="text" name="testid" id="testid" />

into javascript <script></script>
 
when i tried it...it opens a new window...
it does not display it on existing window.
 
this is what i am trying..
---------------------
if doctorNodes is null when <doctor> has no <doctors>

here is scenario.
1. when it opens the page, the page empty text field for doctors.
2. when it select the medical field name, it displays doctors when <doctor> has no <doctors>. otherwise it has to display empty text filed for doctors.
----------------------

here is my org. code..

---------------
it gets doctor's name based on medicali and display it as select box.

but I want to add text filed if doctorNodes is null

for example,

if doctorNodes is null
{<input type="text" name="medicalfield" id="medicalfield" />}
else
{// make selectBox
selectBox.options.add(new Option(doctorNodes[j].getAttributeNode("doctor_name").nodeValue));
}

How can i do that based on my code..





[ file name: medical.xsl ]
<xsl:stylesheet version="1.0" xmlns:xalan=" >
<script>
var xmlHttp

function showCustomer(str)
{
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
{
alert ("Your browser does not support AJAX!");
return;
}

var url='../stat/medical.xml?patient_id=<xsl:value-of select="pid" />&amp;medicalid='+str;

xmlHttp.onreadystatechange=stateChanged;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}

function stateChanged()
{
if (xmlHttp.readyState==4)
{
var xmlDoc=xmlHttp.responseXML.documentElement;
var selectBox = document.getElementById("medicalid");

for(var y=selectBox.options.length; y > 0; y--)
{
selectBox.remove(selectBox.options[y]);
}

var doctorNodes = xmlDoc.getElementsByTagName("doctors")[0].getElementsByTagName("doctor")
for (j=0;j<doctorNodes.length;j++)
{
selectBox.options.add(new Option(doctorNodes[j].getAttributeNode("doctor_name").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" > </select>
</td>
</tr>
</table>
</xsl:stylesheet>


[ file name: ../stat/medical.xml ]


<?xml version="1.0"?>
<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"></doctor>
<doctor doctorid="MDPS" doctor_name="Test_1 M.D"></doctor>
<doctor doctorid="MDPS" doctor_name="Test_3 M.D"></doctor>
</doctors>
<medical>
<stat>
<testarea>
<document>
-------------------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top