Topic: This belongs in the DOM form, but the door was locked. (Page 1 of 1) |
|
|---|---|
|
Paranoid (IV) Inmate From: Willaimsport, PA, US of A the hole i |
posted 09-23-2005 23:05
Is there anyway to add an event handler in IE and Mozilla/Firefox code: <html>
<head>
<title>Adding Properties Dynamicly</title>
<!-- Import the classes -->
<script type="text/javascript" src="./js4/Employee.js"></script>
<script type="text/javascript">
function pageInit()
{
var textBox = document.getElementById("textbox");
var onFocusAttr = document.createAttribute("onfocus");
onFocusAttr.nodeValue = "callMeOnFocus(textbox)";
textBox.setAttributeNode(onFocusAttr);
alert(textBox.getAttribute("onfocus"));
}
function callMeOnFocus(textBox)
{
alert("callMeOnFocus in function");
var changeText = document.getElementById("changeOnFocus");
changeText.innerHTML = textBox.value;
}
</script>
</head>
<body onload="pageInit();">
<div id="changeOnFocus">text</div>
<input type="text" id="textbox" onclick="alert(textBox.value)"/>
</body>
</html>
|
|
Maniac (V) Mad Scientist From: :morF |
posted 09-24-2005 03:32
*whistles casually and boots it over to the DOM forum after unlocking the door* |
|
Maniac (V) Mad Scientist From: 100101010011 <-- right about here |
posted 09-24-2005 03:41
sure. code: <html>
<head>
<title>Adding Properties Dynamicly</title>
<!-- Import the classes -->
<script type="text/javascript">
function pageInit()
{
var textBox = document.getElementById("textbox");
textBox.onfocus = function () {
var changeText = document.getElementById("changeOnFocus");
changeText.innerHTML = this.value;
}
}
</script>
</head>
<body onload="pageInit();">
<div id="changeOnFocus">text</div>
<input type="text" id="textbox"/>
</body>
</html>
|
|
Paranoid (IV) Inmate From: Willaimsport, PA, US of A the hole i |
posted 09-26-2005 19:11
Hey thanks alot! That a list apart article really did the trick! It's all about the custom attributes... |