I know how to access an element by itīs id, but how could I get the id of an element
Letīs say I have
Code JavaScript:var id; function getid() { var get=get the id of the element that triggered the function; id=get alert(id); } <input type="submit" id="test" onclick="getid()">
this is the code I have, but I want to use it for different fields, it works right now, but if the first change to the fields is made on field4 then the script will not work, I found a way around and made it work in my form but I am looking for a way to get the id of an element so I dont have to be looking for "ways around" in the future and also to make my code smaller.
Does anyone know how I can retrieve the id of an element on a onchange or other event?
Code HTML4Strict:<html> <body> <script type="text/javascript"> var x=1; var ids="test"; function fixuplow() { var myvar=(document.getElementById(ids+x).value); var process=(myvar.toLowerCase()); var final=(process.charAt(0).toUpperCase() + process.slice(1)); document.getElementById(ids+x).value=final; x++; } </script> something to up and lower case: <input type="input" id="test" onchange="fixuplow()"> </body> </html>
thanks for your help!!!!!



Reply With Quote



Bookmarks