Jump to content

Passing an HTML objecvt (tag) to JS


Recommended Posts

GreetingsI want to pass the entire <input> object to the JS function to be able to access all of its properties. I can pass individual properties by specifying "this.(property)" as an argument (ie this.value, this.name, etc)my HTML code:

<input name="txtTest" size="20" type="text" value="Test"  onfocus="testTextbox(this)">

BTW, the above does not work.My JS code:

function testTextbox(oTag){ alert(oTag.value); }

But how do I pass the entire object?TIA

Link to comment
Share on other sites

I got it to work ok?? :)

<head><script>function testTextbox(oTag){  alert(oTag.value);   alert(oTag.size);  alert(oTag.name);}</script></head><body><input name="txtTest" size="20" type="text" value="Test" onfocus="testTextbox(this)"></body>

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...