On Mon, 17 May 2004 10:33:49 GMT, harry wrote:
Thanks for that Zero, was hoping to test if a key was pressed in a text box
that has readOnly set.
Any ideas why this returns false regardless of this setting?
Yes. Because the "this" keyword in that context is NOT your HTML input
object.
Try this:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title></title>
</head>
<body>
<script type="text/javascript">
function changedDetails(sender){
if (sender.readOnly)
alert("the element "+sender.name+" is readonly");
else
alert("the element "+sender.name+" is editable");
}
</script>
<input type="text" name="actreqto" maxlength="20" value=""
onkeypress="changedDetails(this);" readonly="readonly" />
</body>
</html>
--
C'ya,
ZER0 :: coder.gfxer.webDesigner();
"Nei film americani, qualsiasi problema che venga considerato
sufficientemente catastrofico, puo' essere risolto facendo esplodere uno
o piu' ordigni nucleari" (ZER0 & Cosimo)
Now playing: "No more chances"