Prototype - $F() Method



The $F() function returns the value of any field input control, like text boxes or drop-down lists. This is a convenience alias of Form.Element.getValue.

The function can take as argument either the element id or the element object itself.

Syntax

$F(element) 

Return Value

Form's element Value.

Example

<html>
   <head>
      <title>Prototype examples</title>
      <script type = "text/javascript" src = "/javascript/prototype.js"></script>
      
      <script>
         function ShowValue() {
            var value = $F('userName');
            alert( 'Entred  Value :' + value);
         }
      </script>
   </head>

   <body>
      <p>Enter any value in the box and then click "Show Value"</p>
      
      <form>
         <input type = "text" id = "userName" value = "Madisetti, Praveen">
         <br/>
         <input type = "button" value = "Show Value" onclick = "ShowValue();"/>
      </form>
      
   </body>
</html>

Output

prototype_utility_methods.htm
Advertisements