View Full Version : Javascript: Obtaining field names
Agent009
09-06-2008, 06:17 AM
Can I use this to obtain the current field name automatically?
<input type="button" name="str" value"Button" onClick="this.form.fieldName;" />
I tried it on Firefox but it doesn't seem to work.
Horus_Kol
09-06-2008, 06:50 AM
1. event names should be all lowercase
<input type="button" name="str" value="Button" onclick="javascript" />
2. also - you're not actually doing anything here... what do you want to do with the field's name?
Agent009
09-06-2008, 06:54 AM
I'm just querying whether it is possible to obtain the field name using the above procedure/statment. The events detailed are purely for demonstration purposes.
Horus_Kol
09-06-2008, 07:13 AM
well, a better way to show it working would be:
<head>
...
<script type="text/javascript">
function display_field_name(input)
{
alert(input.name);
}
</script>
...
</head>
<body>
...
<input type="button" name="str" value="Button" onclick="display_field_name(this)" />
...
</body>
rangana
09-06-2008, 07:24 AM
I believe this is a cross post (http://www.htmlforums.com/client-side-scripting/t-javascript-using-variables-107512.html)
Agent009
09-06-2008, 07:56 AM
Ok that's nice, thanks for the reply.
vBulletin® v3.6.7, Copyright ©2000-2009, Jelsoft Enterprises Ltd.