Good Day Tekkies,
I've been writing some javascript functions to use as events in an HTML page for various reasons. Form validation, rollovers, etc.
In the functions, I've been hard-coding the parent HTML object's ID to make it work, but this make my code hard to reuse in the future, as I will have to edit my javascript to use the proper IDs.
I'm wondering if there is a way for me to pass the HTML object ID as a parameter of the javascript function call.
Ex.:
I've seen other developers using the this and the self keywords in either their JS or HTML, and I've tried this route, but I don't think I'm implementing it correctly, as I can't get it to work. If this is CLOSE to right, I'd like an explanation that I can refer to. Does any tek have such a reference?
If I'm all wrong there, I'm willing to hear any other advice.
Thanks in advance,
Dave
David Layzell, A+, Project+
Computer Network Engineering Grad
5 years SysAdmin, 11 years hobbyist Dev
I've been writing some javascript functions to use as events in an HTML page for various reasons. Form validation, rollovers, etc.
In the functions, I've been hard-coding the parent HTML object's ID to make it work, but this make my code hard to reuse in the future, as I will have to edit my javascript to use the proper IDs.
I'm wondering if there is a way for me to pass the HTML object ID as a parameter of the javascript function call.
Ex.:
Code:
<div id="testdiv" onmouseover="js_function([b]<div id>[/b])"></div>
I've seen other developers using the this and the self keywords in either their JS or HTML, and I've tried this route, but I don't think I'm implementing it correctly, as I can't get it to work. If this is CLOSE to right, I'd like an explanation that I can refer to. Does any tek have such a reference?
If I'm all wrong there, I'm willing to hear any other advice.
Thanks in advance,
Dave
David Layzell, A+, Project+
Computer Network Engineering Grad
5 years SysAdmin, 11 years hobbyist Dev