Quote:
Originally Posted by acoder
Possibly the onChange gets fired because the value has been altered by the Javascript. The onchange most likely fires because when you lost focus the value is different from when you gained focus. One possible workaround is to give focus to another element after/before the change. If that doesn't work, post your code.
Hello,
Thanks for the solution, but it is not working that way..Here is the code.
Custom tag is defined as:
[HTML]<input type="text" name="#attributes.name#"
size="13" maxlength="13" onChange="#attributes.onChange#
value="#attributes.value#">
[/HTML]
The Instance of Custom tag is created as:
[HTML]<CF_mytag
name = "m"
value = ""
onChange = "mChanged();"
>
<CF_mytag
name = "x"
value = ""
onChange = "xChanged();"
>[/HTML]
Let say I have entered X1 value in texbox m. Then m.value=X1 and database query will fetch a corresponding M1 for the X1 value which should go in texbox m and the value of texbox m is switched to texbox x.
The Javascript functions are identical,
- function mChanged()
-
{
-
with (document.all)
-
{
-
l_m_text = m.value;
-
if (sComponent.m != "") //This is received from Database
-
m.value = sComponent.m;
-
else if (l_m_text != "")
-
alert("Invalid");
-
x.value = sComponent.x;
-
}
-
}
-
-
function xChanged()
-
{
-
with (document.all)
-
{
-
l_x_text = x.value;
-
if (sComponent.m != "") //This is received from Database
-
x.value = sComponent.x;
-
else if (l_x_text != "")
-
alert("Invalid");
-
m.value = sComponent.m;
-
}
-
}