# Web Development > HTML & CSS Textfield onchange function...

## psuresh1982

In my html page, i am using the following code.

input type="text" name="result" id="res" value="PASS" onchange="change_result();"

The above function is working when the user change the text on the textfield. But if i change the value of the textfield dynamically(using javascript function)it is not working. 

Can anyone tell me why is not working? which function i am using here?

--------------------
suresh

----------


## daisy_deepa

S...even i also face the same problem...
I just give one example , check it out whether it works......
Example:
	function fun1()
	{
		if(document.f.na.value=="hello")
		{
		}
		else
		{
		alert("Text Changed")
		}
	}
	function fun2()
	{
	var mylist=document.getElementById("lang")
	document.getElementById("na").value=mylist.options[mylist.selectedIndex].text
	}

form name=f>
	Language  : select id=lang onchange=fun2(),fun1()>
			option selected>Java
			option>J2ME
			option>C#
			option>Dot Net
		      /select>
	Favorite Language is  :input type=Text name=na value="hello" onchange=fun1()>

/form>

----------


## mythbe

A client side code cannot call another client side function which is connected to a control as if the user types or moves the focus from the textfield the client side function would be called as the event takes place with the help of the user. but if the value of the textfield is changed thru a javascript function then the event onChange() wont fire as it looks for the user input change which doesnt happen in case of value change thru javascript..

For more details visit: mithunondotnet.wordpress.com

----------

