>> Barry, would you mind showing a snippet of your client-side logic
that
would deal with this XML?
here you go
in this particular case, the business logic says that if an address is
linked then some (but not all) fields are read-only. Which fields are
read-only depends on the entity the address belongs to.
so client-side this means that the "linked" attribute runs the read-only
part.
var bReadOnly = false;
if (xField.getAttribute("linked") == "true"){
bReadOnly = true;
}
the point is that the business logic is not officially in the JS - the
JS just reacts to the format of the data. The business logic layer is
still driving it by formatting the data to meet those business rules.
Then consumers of that data re-act accordingly.
note: we've had a change of spec so I'm going to have to re-write this
but because it's using XML I can add attributes and nodes all over the
shop and then write the JS to handle it.
I'm no JS or XML guru but I know what I want to do. I'm still trying to
figure out some xml + JS tricks (that's why this codesnip is so kludgy)
but I hope this helps.
cheers
barry.b
<script language="JavaScript">
var studcode = "<cfoutput>#URL.id#</cfoutput>";
var progressText = "Loading...";
var oXMLHTTP = new ActiveXObject("Msxml2.XMLHTTP");
function loadXML(theForm){
var addresscode =
theForm.addrType.options[theForm.addrType.selectedIndex].value;
var sUri = "xmlremote.cfm?addresscode=" + addresscode +
"&studcode=" + studcode;
// Create an instance of the XML HTTP Request object
// Execute the request
oXMLHTTP.Open("GET", sUri, false);
oXMLHTTP.Send();
var xmlAddress = oXMLHTTP.responseXML;
var xmlFields =
xmlAddress.documentElement.childNodes;
for(var f = 0; f < xmlFields.length; f++){
var xField = xmlFields[f];
var strNodeValue = "";
var bReadOnly = false;
var xTagName = xField.tagName;
var xNode =
xField.childNodes[0];
//alert("xTagName is: " +
xTagName + " and xNode: " + xNode)
if(!(xNode == null)){
strNodeValue =
xNode.nodeValue;
if
(xField.getAttribute("linked") == "true"){
bReadOnly =
true;
}
}
switch(xTagName){
case "add_num" :
theForm.ADDNUM.value = strNodeValue;/******** it's a hidden field so
doesn't need "protection"... ************/;break;
case "salutation" :
theForm.SALUTATION.value = strNodeValue; theForm.SALUTATION.readOnly =
bReadOnly; break;
case "mailing_name" :
theForm.mailing_name.value = strNodeValue; theForm.mailing_name.readOnly
= bReadOnly; break;
case "mailing_name2" :
theForm.mailing_name2.value = strNodeValue;
theForm.mailing_name2.readOnly = bReadOnly; break;
case "bus_phone" :
theForm.bus_phone.value = theForm.bus_phone.readOnly = bReadOnly; break;
case "home_phone" :
theForm.homephone.value = strNodeValue; theForm.homephone.readOnly =
bReadOnly; break;
case "mob_phone" :
theForm.mobphone.value = strNodeValue; theForm.mobphone.readOnly =
bReadOnly; break;
case "e_mail" :
theForm.email.value = strNodeValue; theForm.email.readOnly = bReadOnly;
break;
case "fax" :
theForm.FAX.value = strNodeValue; theForm.FAX.readOnly = bReadOnly;
break;
case "dpid_text" :
theForm.dpid_text.value = strNodeValue; theForm.dpid_text.readOnly =
bReadOnly; break;
case "addr1" :
theForm.ADDR1.value = strNodeValue; theForm.ADDR1.readOnly = bReadOnly;
break;
case "addr2" :
theForm.ADDR2.value = strNodeValue; theForm.ADDR2.readOnly = bReadOnly;
break;
case "addr3" :
theForm.ADDR3.value = strNodeValue; theForm.ADDR3.readOnly = bReadOnly;
break;
case "country" :
theForm.COUNTRY.value = strNodeValue; theForm.COUNTRY.readOnly =
bReadOnly; break;
case "town_sub" :
theForm.townsub.value = strNodeValue; theForm.townsub.readOnly =
bReadOnly; break;
case "state_code" :
theForm.statecode.value = strNodeValue; theForm.statecode.readOnly =
bReadOnly; break;
}
}
}
</script>
----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email
to [EMAIL PROTECTED] with the words 'unsubscribe cfcdev'
in the message of the email.
CFCDev is run by CFCZone (www.cfczone.org) and supported
by Mindtool, Corporation (www.mindtool.com).
An archive of the CFCDev list is available at
[EMAIL PROTECTED]