Hello,
I am new to javascript and am now trying to master some of the syntax.
I have fabricated the following script:
-code----------------------------------------
<html>
<head>
<title></title>
<script language="JavaScript">
function colorPreview(sender, receiver) {
eval("pollForm." + receiver + ".style.backgroundColor=" + "pollForm." + sender + ".value");
}
</script>
</head>
<body>
<form name="pollForm" method="POST" action="">
<input type="text" name="input1" size="7" MAXLENGTH=7 style="width: 120">
<input type="text" name="input2" size="20" style="width: 20">
<input type="button" value=http://www.webdeveloper.com/forum/archive/index.php/"Submit" name="B1" onClick="colorPreview('input1', 'input2')">
</form>
</body>
</html>
-code----------------------------------------
As you can see there is an onClick handler that calls the function: colorPreview()
and populates the variables "sender" and "receiver" in this function.
The function then, in its turn, constructs the action to change the backgroundColor
of an input field called : "input2".
I want to however execute this function as someone is typing in the "input1" field (or even better: as the value of input1 changes).
I've tried to find handlers for this in several dictionaries on the web, but have had no luck yet.
I come from a background of PHP and Flash.... In flash for example we can create listeners to monitor
an object, in order to take action if aspects about that object change. So I am wondering if there are
similar methods in JavaScript.....
If anyone could point me into the direction of a solution that would be greatly appreciated.
Regards,
Hans Prins
<!-- e --><a href="mailto:[email protected]">[email protected]</a><!-- e -->
I am new to javascript and am now trying to master some of the syntax.
I have fabricated the following script:
-code----------------------------------------
<html>
<head>
<title></title>
<script language="JavaScript">
function colorPreview(sender, receiver) {
eval("pollForm." + receiver + ".style.backgroundColor=" + "pollForm." + sender + ".value");
}
</script>
</head>
<body>
<form name="pollForm" method="POST" action="">
<input type="text" name="input1" size="7" MAXLENGTH=7 style="width: 120">
<input type="text" name="input2" size="20" style="width: 20">
<input type="button" value=http://www.webdeveloper.com/forum/archive/index.php/"Submit" name="B1" onClick="colorPreview('input1', 'input2')">
</form>
</body>
</html>
-code----------------------------------------
As you can see there is an onClick handler that calls the function: colorPreview()
and populates the variables "sender" and "receiver" in this function.
The function then, in its turn, constructs the action to change the backgroundColor
of an input field called : "input2".
I want to however execute this function as someone is typing in the "input1" field (or even better: as the value of input1 changes).
I've tried to find handlers for this in several dictionaries on the web, but have had no luck yet.
I come from a background of PHP and Flash.... In flash for example we can create listeners to monitor
an object, in order to take action if aspects about that object change. So I am wondering if there are
similar methods in JavaScript.....
If anyone could point me into the direction of a solution that would be greatly appreciated.
Regards,
Hans Prins
<!-- e --><a href="mailto:[email protected]">[email protected]</a><!-- e -->