View Single Post
Old 05-15-2007, 04:29 PM   #2 (permalink)
Vormund
 
Monster Techie

Join Date: May 2004

Location: Tucson, AZ, USA

Posts: 1,183

Vormund

Send a message via AIM to Vormund Send a message via MSN to Vormund Send a message via Yahoo to Vormund
Default Re: quick javascript help

Using the getElementById it can be done easily, one example below:

HTML Code:
<html>
  <head>
    <script type="text/javascript">
      function referenceMe( fieldID )
      {
        var field = document.getElementById( fieldID );
        alert( "The value of the field " + fieldID + " is: " + field.value );
      }
    </script>
  </head>
  <body>
    <input type="text" id="test@code" onkeyup="javascript:referenceMe( this.id )">
  </body>
</html> 
Or if you wanted to pass the field id in the function itself, you'd just surround it with single quotes, eg:
onkeyup="javascript:referenceMe( 'test@code' )"

Sorry, this wasn't all too quick.
__________________

Last edited by Vormund; 05-15-2007 at 04:31 PM.
Vormund is offline