atributo del método de formulario HTML DOM
objeto de formulario
Definición y Uso
Método de conjuntos de propiedades o devuelve el método de formulario valores de los atributos.
atributo method formular cómo enviar los datos del formulario (datos del formulario enviado a la dirección especificada en el atributo de acción).
gramática
formObject.method=value
atributo del método puede tener los siguientes valores:
值 | 描述 |
---|---|
get | 在 URL 中添加表单数据: URL?name=value&name=value (默认) |
post | 使用 http post方法提交表单数据 |
Soporte para el navegador
Todos los principales navegadores soportan atributo del método
Nota: Internet Explorer si no hay un método definido atributo devuelve "get" (por defecto), otros navegadores no devuelve ningún valor.
Ejemplos
Ejemplos
Las devoluciones método de transmisión de datos del formulario:
<html>
<body>
<form id="frm1" action="form_action.html" method="get">
First name: <input type="text" name="fname" value="Donald"><br>
Last name: <input type="text" name="lname" value="Duck"><br>
<input type="submit" value="Submit">
</form>
<script>
document.write(document.getElementById("frm1").method);
</script>
</body>
</html>
<body>
<form id="frm1" action="form_action.html" method="get">
First name: <input type="text" name="fname" value="Donald"><br>
Last name: <input type="text" name="lname" value="Duck"><br>
<input type="submit" value="Submit">
</form>
<script>
document.write(document.getElementById("frm1").method);
</script>
</body>
</html>
Los ejemplos de la salida anterior:
get
Trate »
objeto de formulario