runninl8
02-14-2005, 08:53 PM
Hello,
I have recently had to get back into the development scene and have been playing with xforms,xml,xhtml and javascript. What I am trying to accomplish is a dynamic data entry page. I am not sure if this is possible but from my efforts I have at least been able to get the labels to load. Any help that could be provided would be appreciated or another way of doing it. TIA
one note when I viewed the pages as listed below I am able to view the model through the DOM inspector but the input/output fields do not generate. However when I place the script into the onload in the body the model does not generate and the browser seems to be stuck processing.
Thanks again
runninl8
body.js
<!---
if (document.implementation && document.implementation.createDocument)
{
xmlDoc = document.implementation.createDocument("", "", null);
}
else if (window.ActiveXObject)
{
xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
}
else
{
alert('Your browser can\'t handle this script');
}
xmlDoc.async = false;
xmlDoc.load("FormLabels.xml");
Name = "FormLabelData";
xmlObj=xmlDoc.getElementsByTagName(Name);
var borrowerNode = xmlObj[0].childNodes[1].childNodes[1]
document.write("<table>")
if (borrowerNode.hasChildNodes())
{
var x = 0;
var xmlChildNode,nodeVal=' ',xmlnodeName=' ';
var FormInput = ""
var FormLabel =""
while(borrowerNode.childNodes[x])
{
xmlChildNode=borrowerNode.childNodes[x];
if(xmlChildNode.nodeType != 3) // #text == 3
{
document.write("<tr>")
FormLabel="<td><xf:label>"+xmlChildNode.firstChild.nodeValue+"</xf:label></td>";
FormInput="<td><xf:input ref=\"instance(\'Demographics\')/English/PersonalDemographics/"+
xmlChildNode.tagName+"\"></xf:output></td>";
document.write(FormLabel)
document.write(FormInput)
document.write("</tr>")
}
x++
}
}
document.write("</table>")
--->
display.htm
<!---
<?xml version='1.0' encoding='iso-8859-1'?>
<!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" xmlns:xf="http://www.w3.org/2002/xforms">
<head>
<meta http-equiv="Content-Script-Type" content="text/javascript" />
<meta http-equiv="Content-Type" content="text/htm" charset=iso-8859-1" />
<title>Load You **** Forms</title>
<xf:model>
<xf:instance src="file:///FormLabels.xml" id="Demographics">
</xf:instance>
<xf:submission id="s1" ref="instance('Demographics')" method="put" action="file:///FormLabels.xml"/>
</xf:model>
</head>
<body>
<script type="text/javascript" src="body.js"></script>
<xf:submit submission="s1"><xf:label>Save data to file</xf:label></xf:submit>
</body>
</html>
--->
formlabels.xml
<!---
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE FormLabelData []>
<FormLabelData xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="file:///c:/FormLabels/FormLabels.xsd">
<English>English
<PersonalDemographics>Demographics
<FirstName>First Name</FirstName>
<MiddleName>Middle Name</MiddleName>
<LastName>Last Name</LastName>
<SSN>SSN (optional)</SSN>
<Streetaddress>Street Address</Streetaddress>
<Apt>Apt#(If applicable)</Apt>
<City>City</City>
<State>State or Province</State>
<Country>Country</Country>
<Telephone>Area Code+Telephone#</Telephone>
<BirthDate>Date of Birth</BirthDate>
<BirthCity>Place of Birth</BirthCity>
<Race>Race/Nationality</Race>
<Language>Native Language</Language>
<Marital>Marital Status</Marital>
</PersonalDemographics>
--->
I have recently had to get back into the development scene and have been playing with xforms,xml,xhtml and javascript. What I am trying to accomplish is a dynamic data entry page. I am not sure if this is possible but from my efforts I have at least been able to get the labels to load. Any help that could be provided would be appreciated or another way of doing it. TIA
one note when I viewed the pages as listed below I am able to view the model through the DOM inspector but the input/output fields do not generate. However when I place the script into the onload in the body the model does not generate and the browser seems to be stuck processing.
Thanks again
runninl8
body.js
<!---
if (document.implementation && document.implementation.createDocument)
{
xmlDoc = document.implementation.createDocument("", "", null);
}
else if (window.ActiveXObject)
{
xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
}
else
{
alert('Your browser can\'t handle this script');
}
xmlDoc.async = false;
xmlDoc.load("FormLabels.xml");
Name = "FormLabelData";
xmlObj=xmlDoc.getElementsByTagName(Name);
var borrowerNode = xmlObj[0].childNodes[1].childNodes[1]
document.write("<table>")
if (borrowerNode.hasChildNodes())
{
var x = 0;
var xmlChildNode,nodeVal=' ',xmlnodeName=' ';
var FormInput = ""
var FormLabel =""
while(borrowerNode.childNodes[x])
{
xmlChildNode=borrowerNode.childNodes[x];
if(xmlChildNode.nodeType != 3) // #text == 3
{
document.write("<tr>")
FormLabel="<td><xf:label>"+xmlChildNode.firstChild.nodeValue+"</xf:label></td>";
FormInput="<td><xf:input ref=\"instance(\'Demographics\')/English/PersonalDemographics/"+
xmlChildNode.tagName+"\"></xf:output></td>";
document.write(FormLabel)
document.write(FormInput)
document.write("</tr>")
}
x++
}
}
document.write("</table>")
--->
display.htm
<!---
<?xml version='1.0' encoding='iso-8859-1'?>
<!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" xmlns:xf="http://www.w3.org/2002/xforms">
<head>
<meta http-equiv="Content-Script-Type" content="text/javascript" />
<meta http-equiv="Content-Type" content="text/htm" charset=iso-8859-1" />
<title>Load You **** Forms</title>
<xf:model>
<xf:instance src="file:///FormLabels.xml" id="Demographics">
</xf:instance>
<xf:submission id="s1" ref="instance('Demographics')" method="put" action="file:///FormLabels.xml"/>
</xf:model>
</head>
<body>
<script type="text/javascript" src="body.js"></script>
<xf:submit submission="s1"><xf:label>Save data to file</xf:label></xf:submit>
</body>
</html>
--->
formlabels.xml
<!---
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE FormLabelData []>
<FormLabelData xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="file:///c:/FormLabels/FormLabels.xsd">
<English>English
<PersonalDemographics>Demographics
<FirstName>First Name</FirstName>
<MiddleName>Middle Name</MiddleName>
<LastName>Last Name</LastName>
<SSN>SSN (optional)</SSN>
<Streetaddress>Street Address</Streetaddress>
<Apt>Apt#(If applicable)</Apt>
<City>City</City>
<State>State or Province</State>
<Country>Country</Country>
<Telephone>Area Code+Telephone#</Telephone>
<BirthDate>Date of Birth</BirthDate>
<BirthCity>Place of Birth</BirthCity>
<Race>Race/Nationality</Race>
<Language>Native Language</Language>
<Marital>Marital Status</Marital>
</PersonalDemographics>
--->