原型 - $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>

輸出

prototype_utility_methods.htm
廣告
© . All rights reserved.