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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

onpropertychange event not firing consistently

Status
Not open for further replies.

kathiefoley

Programmer
Oct 18, 2002
2
US
I am using IE6.0 and MSXML4.0.

I created a table which is bound to an XML dataisland. I attached a behavior to the bound input fields. The behavior has code behind the

onpropertychange event, which displays an expando property's content in an adjacent field (just for testing purposes). My problem is that the

onpropertychange event does not fire consistently for all the bound fields. If you run my example code and keep clicking the refresh button,

you will notice that the "OPC Test" field gets populated intermittantly.

Is this an IE6.0 bug? Has anyone else seen this behavior? Any workarounds? I would like to rely on the onpropertychange event firing for

each bound field to be able to implement masking.

Here is my sample DHTML which I named sysMask.html:
Code:
<HTML>
<HEAD>
<style type=&quot;text/css&quot;>  
.mask { behavior:url(sysMask.htc); color: red; }
</style>
</HEAD>
<BODY>
<XML ID=&quot;xmlSample&quot; SRC=&quot;sample.xml&quot;></XML>
<TABLE id=&quot;grdTest&quot; datasrc=&quot;#xmlSample&quot;>
<THEAD>
	<TR>
		<TD><LABEL>OPC Test</LABEL></TD>
		<TD><LABEL>OPC Test</LABEL></TD>
		<TD><LABEL>OPC Test</LABEL></TD
	</TR>
</THEAD>
<TBODY>
	<TR>
		<TD>
			<DIV>
				<INPUT id=&quot;mask_mskTest&quot; xMaskType=&quot;number&quot; />
				<INPUT id=&quot;mskTest&quot; class=&quot;mask&quot; xMaskType=&quot;number&quot; datafld=&quot;NUM&quot; />
			</DIV>
		</TD>
		<TD>
			<DIV>
				<INPUT id=&quot;mask_mskTest2&quot; xMaskType=&quot;percent&quot; />
				<INPUT id=&quot;mskTest2&quot; class=&quot;mask&quot; xMaskType=&quot;percent&quot; datafld=&quot;PERCENT&quot; />
			</DIV>
		</TD>
		<TD>
			<DIV>
				<INPUT id=&quot;mask_mskTest3&quot; xMaskType=&quot;date&quot; />
				<INPUT id=&quot;mskTest3&quot; class=&quot;mask&quot; xMaskType=&quot;date&quot; datafld=&quot;DATE&quot; />
			</DIV>
		</TD
	</TR>
</TBODY>
</TABLE>
</BODY>
</HTML>

Here is my sample behavior (HTC) which I named sysMask.htc:
Code:
<PUBLIC PROPERTY NAME=&quot;xMaskType&quot; value=&quot;number&quot;/>
<PUBLIC:ATTACH EVENT=&quot;onpropertychange&quot; onevent=&quot;DoPropChange()&quot; />
<SCRIPT LANGUAGE=&quot;jscript&quot;>
function DoPropChange()
{	
	var maskElem = element.parentElement;
	var formatElem = maskElem.firstChild;
	
	formatElem.innerText = element.xMaskType;
}
</SCRIPT>

Here is my sample xml document which I named sample.xml:
Code:
<?xml version=&quot;1.0&quot;?>
<MASKLIST>
 <ITEM>
  <NUM>10000.12</NUM>
  <DATE>1998-03-07</DATE>
  <PERCENT>10</PERCENT>
  <CUST>10AB20</CUST>
 </ITEM>
 <ITEM>
  <NUM>14334.12233</NUM>
  <DATE>1999-03-23</DATE>
  <PERCENT>20</PERCENT>
  <CUST>20AB20</CUST>
 </ITEM>
 <ITEM>
  <NUM>0.76</NUM>
  <DATE>2000-12-07</DATE>
  <PERCENT>45</PERCENT>
  <CUST>30AB20</CUST>
 </ITEM>
 <ITEM>
  <NUM>1.76</NUM>
  <DATE>2000-12-08</DATE>
  <PERCENT>45.3</PERCENT>
  <CUST>30AB44</CUST>
 </ITEM>
 <ITEM>
  <NUM>33.90</NUM>
  <DATE>2000-10-07</DATE>
  <PERCENT>45</PERCENT>
  <CUST>30AC30</CUST>
 </ITEM>
 <ITEM>
  <NUM>-10.76</NUM>
  <DATE>2000-02-07</DATE>
  <PERCENT>100</PERCENT>
  <CUST>30AC20</CUST>
 </ITEM>
</MASKLIST>

If you put all three files in one directory and run the sysMask.html file you will see my test case.

Any help is appreciated!

Thanks,

Kathie
 
I've had a simular problem with IE6.0 and found that at least in my situation, making sure the browser does not cache anything helps with the refresh.

Try out this code below:

If you frequently update the content of a Web page and would like to keep it from being cached, try adding the the following commands to your page. The expires tag will work on most browsers. The date specified should be past so that the browser will either discard the cached copy or not cache it at all. The no-cache command will prevent Netscape Navigator from caching a page locally.

<META HTTP-EQUIV=&quot;Expires&quot; CONTENT=&quot;Tue, 01 Jan 1980 1:00:00 GMT&quot;>
<META HTTP-EQUIV=&quot;Pragma&quot; CONTENT=&quot;no-cache&quot;>
&quot;did you just say Minkey?, yes that's what I said.&quot;

MrGreed
 
Try swapping the <div>'s for <span>'s. Typically IE treats these tags equally but this might be one of those times where it makes a difference.
 
Thanks for the feedback!

I found a solution to my problem. I used two events (onpropertychange and onreadystatechange), between the two events my function gets called for each bound input field. I haven't figured out why, but I am just glad that it works.

Here is my altered behavior:

<PUBLIC PROPERTY NAME=&quot;xMaskType&quot; value=&quot;number&quot;/>
<PUBLIC:ATTACH EVENT=&quot;onpropertychange&quot; onevent=&quot;DoPropChange()&quot; />
<PUBLIC:ATTACH EVENT=&quot;onreadystatechange&quot; onevent=&quot;DoPropChange()&quot; />
<SCRIPT LANGUAGE=&quot;jscript&quot;>
function DoPropChange()
{
var maskElem = element.parentElement;
var formatElem = maskElem.firstChild;

formatElem.innerText = element.xMaskType;
}
</SCRIPT>

Thanks,

Kathie
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top