I've got a Drupal module that creates nodes. In my node_form hook I have several form fields that are returned. For several reasons I need to access those fields on the fly in javascript ... here's the problem.
Drupal creates form fields like this
------------
<form action="/node/add/song" method="post" name="frmSongForm" enctype="multipart/form-data" id="node-form">
<input type="text" maxlength="64" class="form-text required" name="edit[firstname]" id="edit-firstname" size="40" value="The Yellow Dart" />
</form>
-------------
This is nice and makes my life easier on the php side, but it makes things a big problem when I try to get a handle on the field in javascript! For instance I try the following:
-------------
firstname = document . frmSongForm . edit[firstname] . value;
-------------
And javascript says 'undefined!'. I have looked high and low for a way to get a grasp on these form fields using javascript and nobody seems to have a solution. Am I missing something obvious here? Or is this truly impossible.
PS: Yes, If I make up my own form field I can access it just fine. However, this is nasty and a hack. For instance, the following code works just fine (NOTE: The name of the field!):
-------------