Prototype-dollarf-method

提供:Dev Guides
移動先:案内検索

プロトタイプ-$ F()メソッド

$ F()関数は、テキストボックスやドロップダウンリストなどのフィールド入力コントロールの値を返します。 これは、_Form.Element.getValue_の便利なエイリアスです。

この関数は、要素IDまたは要素オブジェクト自体のいずれかを引数として取ることができます。

構文

$F(element)

戻り値

フォームの要素値。

<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>

出力