Jump to content

DOM event


Guest eirche.net

Recommended Posts

Guest eirche.net
<form><input type="text" name="user" onchange="alert('message');"></form>

the above code works as expected.i like to make something like this. but it doesn't work.

<form><input type="text" name="user"></form><script type="text/javascript" >document.forms[0].user.onchange="alert('message');";</script>

http://msdn.microsoft.com/workshop/author/...ts/onchange.asphttp://www.w3schools.com/htmldom/dom_obj_text.asp

Link to comment
Share on other sites

Well, i don't think document.forms[0].event works. What i suggest:

<html><head><script type="text/javascript">function ya(){alert("OMG! MESSAGE HERE! OMG!")}</script></head><body><form><input type="text" value="blah" onchange="ya()"></form></body></html>

That is multi browser, and will work perfectly.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...